Skip to content

fix(agent): retain ReAct tool calls for output and memory - #21444

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
Ricky-RC:fix/agent-tool-call-history
Oct 29, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
Ricky-RC:fix/agent-tool-call-history

Conversation

@Ricky-RC

Copy link
Copy Markdown
Contributor

Summary

Successful Go ReAct runs execute tools and return an answer, but their final assistant message usually has no ToolCalls. Reading only that message leaves the Agent's tool_calls output empty and skips tool-call memory summarization.

Collect complete calls in the existing per-turn stream checker and attach this run's history to the final message, including an empty final stream. History collection stays within each Agent's own stream checker; parent and child histories remain separate, and message and artifact streaming are unchanged.

Validation

  • Added real RunAgent coverage through Canvas, AgentComponent, ReAct, the model HTTP adapter, MCP transport, and session persistence, using deterministic external HTTP fixtures.
  • Covered direct and deferred execution, multiple/parallel calls, fragmented arguments, nested/concurrent Agents, empty final streams, failures, cancellation, and a second direct-answer turn in the same session.
  • The same service tests against the unmodified source fail the five successful-tool cases and pass the three controls.
  • bash build.sh --test -p 4 -v -run ToolHistory ./internal/agent/component/ ./internal/service/ passed with the repository's CGO/static native libraries.
  • 345 related top-level tests passed in the native environment: selected Agent/component/service regressions plus the full Canvas/runtime packages. The native unit-test packages run by build.sh also passed.

No browser E2E, race-detector run, or live-provider model calls were performed.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 397d690c-cc5c-4261-a72b-872b131ef8a3
Commits

Reviewing files that changed from the base of the PR and between 349ebe8 and 77b9ea7.

Files selected for processing: 1
  • internal/agent/component/agent.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The agent now collects streamed tool calls separately for each run, merges call fragments at the end of each model turn, and attaches collected calls to the returned assistant message. Component and service tests cover nested, concurrent, and service-level tool-call history.

Changes: Tool-call history

Layer / File(s) Summary
Per-run tool-call collection
internal/agent/component/agent.go
Each run gets a separate tool-call collector. The stream scanner merges fragments at EOF and the runner attaches collected calls to the returned assistant message, including when no response chunks were produced.
Component history validation
internal/agent/component/agent_tool_history_test.go
Tests cover call history across nested agents and concurrent roots, and reconstruction of streamed tool-call fragments by round.
Service history integration
internal/service/agent_tool_history_test.go
An integration test covers streamed and deferred output, parallel calls, direct answers, empty streams, tool failures, cancellation, and persisted memory.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant runEinoReActAgent
  participant scanAllStreamForToolCall
  participant contextCollector
  participant assistantMessage
  runEinoReActAgent->>scanAllStreamForToolCall: pass run context and stream
  scanAllStreamForToolCall->>contextCollector: append concatenated calls at EOF
  runEinoReActAgent->>assistantMessage: attach collected calls
Loading

Suggested reviewers: wangq8

Merge Risk: Minimal · up to 77b9e

The tool-call history changes have no established merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the change: it fixes ReAct tool-call retention so Agent output and memory keep the tool calls. It follows the conventional-commit style and matches the summary, which collects complete…
Description check Passed The description follows the template's Summary section. It explains the problem (successful ReAct runs leave the final message's ToolCalls empty, so tool_calls output is empty and memory summarization…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: it fixes ReAct tool-call retention so Agent output and memory keep the tool calls. It follows the conventional-commit style and matches the summary, which collects complete tool calls per turn and attaches them to the final message for output and memory.

Full details: Description check

Explanation

The description follows the template's Summary section. It explains the problem (successful ReAct runs leave the final message's ToolCalls empty, so tool_calls output is empty and memory summarization is skipped), the fix (per-turn stream checker collects complete calls and attaches them to the final message), and scope (parent and child histories stay separate; message and artifact streaming are unchanged). It also adds a Validation section with test coverage, results, and the items not run. The template has only a Summary heading, so the extra section does not break the structure.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit watched the call-stream flow,
As fragments joined and IDs showed.
Each run kept its own history,
While nested roots stayed free,
And calls returned when streams were done.

Comment @coderabbitai help to get the list of available commands.

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@6ba3i 6ba3i added the ci Continue Integration label Oct 28, 2026
@Ricky-RC

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @6ba3i! The Infinity CI logs show the model provider returning HTTP 429 / code 1113 (insufficient balance or no available resource package). Could a maintainer check the CI model quota and rerun the failed and cancelled jobs once resolved?

@wangq8
wangq8 merged commit f80f5c4 into infiniflow:main Oct 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants