fix(loop): enrich trace entries with call_id for tool-call correlation#168
Closed
zwrong wants to merge 2 commits into
Closed
fix(loop): enrich trace entries with call_id for tool-call correlation#168zwrong wants to merge 2 commits into
zwrong wants to merge 2 commits into
Conversation
- Add call_id to tool_call traces in both single and parallel execution - Replace truncated result preview with full result in tool_result trace Signed-off-by: zwrong <1003912034@qq.com>
"result" replaces "preview" means full payload goes into trace.jsonl,
which breaks the CLI trace replay consumer that reads entry.get("preview", "").
200-char preview is sufficient for quick CLI replay; full result would
force every consumer to handle both old "preview" and new "result" fields.
Signed-off-by: zwrong <1003912034@qq.com>
warren618
added a commit
that referenced
this pull request
Jun 3, 2026
Adds the tool call_id to the tool_call and tool_result trace records so a result can be correlated back to its originating call when replaying a trace. Keeps the existing [:200] truncation on serialized args to avoid bloating trace files with large tool inputs. Equivalent to #168 (arg truncation preserved). Co-authored-by: zwrong <1003912034@qq.com>
Collaborator
|
Thanks for spotting this, @zwrong — correlating |
warren618
added a commit
that referenced
this pull request
Jun 3, 2026
…ales Adds the 2026-06-03 News entry (trace call_id correlation #168, dead-doc reference cleanup #166, langchain-community install-warning clarification #167, Gemini thoughtSignature scoped to help-wanted #170) to the English, Chinese, Japanese, Korean, and Arabic READMEs, and collapses the 2026-05-31 entry into the "Earlier news" section to keep three latest entries visible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
call_idtotool_callandtool_resulttrace entries, enabling clear correlation between tool calls and their results intrace.jsonlviacall_idWhy
When replaying agent sessions from
trace.jsonl, there is currently no way to correlate atool_callentry with its correspondingtool_result. The existingiterfield is not sufficient because_execute_parallelruns multiple tool calls within the same iteration:In this scenario,
iteralone (or eveniter + tool) cannot distinguish the twoweb_searchcalls.call_id(the LLM-assigned tool-call identifier) provides a 1:1 join key for request ↔ response correlation regardless of parallelism or duplicate tool names.Separately, the 200-char arg truncation in trace makes post-hoc debugging difficult for tools with large payloads (e.g. code generation).
Changes
agent/src/agent/loop.py(3 lines changed):_execute_parallel(L749)call_id: tc.idto trace, remove[:200]on args_execute_single(L794)_finalize_tool_result(L873)call_id: tc.idtotool_resulttrace entryBefore
After
Test Plan
pytest --ignore=agent/tests/e2e_backtest --tb=short -q) — 2845 passed, 2 skipped, 0 failed. The 2 skipped tests are pre-existing (alpha101_096 NaN ratio, TUSHARE_TOKEN not set), unrelated to this PR.trace.jsonland confirmedcall_idappears on bothtool_callandtool_resultentries, and args are untruncated in traceChecklist
src/agent/,src/session/,src/providers/) without prior discussion