Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(bot): force a tool-free final answer when subagent hits iteration limit (parity with #2810)#2881

Open
r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:fix/subagent-iteration-limit-final-answer
Open

fix(bot): force a tool-free final answer when subagent hits iteration limit (parity with #2810)#2881
r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:fix/subagent-iteration-limit-final-answer

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Follow-up to #2810, on the sister subagent path it never covered.

#2810 made the main agent loop, on reaching the tool-use iteration limit, re-prompt the model with tools=[] to produce a real final answer. The subagent loop (bot/vikingbot/agent/subagent.py) was missed: when iteration 15 still emits tool calls, the while iteration < max_iterations loop exits with final_result=None and returns the placeholder "Task completed but no final response was generated.", throwing away all 15 rounds of search/file work the subagent performed.

Fix — mirror the #2810 pattern in the subagent loop: on hitting the limit with no final content, append a "do not call any more tools" instruction and make one tools=[] call to summarize the gathered context. The placeholder fallback now only triggers if that final call is also empty.

subagent.py calls provider.chat directly (not loop.py's _chat_with_stream_events), so this mirrors the pattern, not the exact streaming call.

Added a regression test mirroring test_agent_loop_makes_final_no_tool_call_when_iteration_limit_reached: it drives 15 tool-call iterations and asserts the extra tools=[] call returns a real answer with the gathered tool results still in context.

… limit

PR volcengine#2810 made the main agent loop, on reaching the tool-use iteration
limit, re-prompt the model with tools=[] to produce a real final answer.
The subagent loop never got the same handling: when iteration 15 still
emits tool calls, the loop exits with final_result=None and returns the
placeholder 'Task completed but no final response was generated.',
discarding every round of search/file work the subagent performed.

Mirror the volcengine#2810 pattern in the subagent loop: on hitting the limit with
no final content, append a 'do not call any more tools' instruction and
make one tools=[] call to summarize the gathered context. Falls back to
the placeholder only if that final call is also empty.

Adds a regression test that drives 15 tool-call iterations and asserts
the extra tools=[] call returns a real answer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant