fix(localagent): stop re-seeding stream accumulator with previous round content (#2329)

When the LLM (e.g. MiniMax-M3) returns multiple rounds after tool calls, the _StreamAccumulator was initialized with initial_content=first_content, causing every subsequent round to repeat the entire first message. Remove the re-seeding so each round starts with a clean accumulator.

Add regression test verifying multi-round tool call content is not duplicated.
This commit is contained in:
DongXiaoming
2026-07-20 16:38:11 +08:00
committed by GitHub
parent 6baeb032a7
commit 76c5003c21
2 changed files with 222 additions and 2 deletions
@@ -523,7 +523,6 @@ class LocalAgentRunner(runner.RequestRunner):
final_msg = stream_accumulator.final_message()
pending_tool_calls = final_msg.tool_calls
first_content = final_msg.content
if isinstance(final_msg, provider_message.MessageChunk):
first_end_sequence = final_msg.msg_sequence
@@ -606,9 +605,13 @@ class LocalAgentRunner(runner.RequestRunner):
)
if is_stream:
# Do NOT re-seed the accumulator with first_content:
# the previous round's text was already pushed to the
# platform adapter. Re-seeding would cause every
# subsequent round to repeat the entire opening line,
# which the platform then forwards as a duplicate message.
stream_accumulator = _StreamAccumulator(
msg_sequence=first_end_sequence,
initial_content=first_content,
remove_think=remove_think,
)