Repository navigation
fix(chat): stop replaying tool calls to the model as "None" - #3758
Conversation
On every non-Claude backend, the history sent to the model before each
request rewrote each tool-call turn as an assistant message whose content
was the word "None", and dropped the call. _structure_history_message
normalised content with str(), msg.get("content", "") returns None when
the key exists, and only the Claude branch kept tool_calls. The model
never saw which tools it had called or with what arguments.
minimax-m3 copied it: on 2 of 4 coding tasks it replied "None", which
became the final answer. No other model printed it across ~90 runs, but
all of them received the same history.
A tool-call turn is now rendered as "[Tool call: name(args)]", the same
text convention tool results already use, with any text the model sent
alongside it kept. None content becomes an empty string, never "None".
The Claude path is unchanged.
Closes amd#3757
Co-Authored-By: Claude Opus 5 <[email protected]>
|
Verdict: Request changes — the fix itself is right and well-targeted; two things should land before merge. Tool-call turns really were reaching every non-Claude backend as an assistant message saying "None", and rendering them as text matches the convention tool results already use. The diff is small, the tests cover the shapes the agent loop actually produces, and the Claude path is left alone. What needs attention:
Real-world evidenceNo evidence bundle was produced for this PR, and the PR itself lists unit tests only. The behavioral claim — that a real model stops answering "None" — rests on the author's prior benchmark observation, not on anything runnable here, and the A/B re-run is listed as still pending. My verdict is based on static review plus the diff's own tests, which I could not execute in this environment (pytest isn't installed on the runner). The change touches no CLI, REST, or Agent UI surface, so no screenshot or request/response capture is expected. 🔍 Technical detailsIssues🟡 Tool-call arguments bypass the truncation budget (
The agent's one-shot overflow-trim retry ( with 🟡 CLAUDE.md → "Run agent evals when changing LLM-affecting code paths — do NOT skip" lists exactly this surface. Worth one run against the coding/tool-use category compared to the committed baseline, since the same request now contains both the native Nits🟢 🟢 PR description carries the Strengths
|
Replaying a tool-call turn as "[Tool call: name(args)]" taught non-Claude models to write calls in that text format instead of calling tools, so the parser rejected them and the turn gave up. On the same 144-run battery that went from 0 to 58 runs ending in "I had trouble formatting my tool call". The turn is now just its own text (empty when it had none). The None -> "" guard stays, so the word "None" is still never replayed. Co-Authored-By: Claude Opus 5 <[email protected]>
|
This review was written against the first version, and both concerns are gone in the current one — the first was proven right before it was removed. The
🔍 Technical details
|
|
The agent eval gate has now run on this PR, together with the other open agent fixes (#3751, #3755, #3758, #3765, #3791) merged onto one branch: no regressions. Every category passes the same scenarios as the unchanged base commit, and no scenario flipped between pass and fail. 🔍 Technical detailsBoth legs ran on the same machine with local
|
…files (amd#3755) Ask the flagship to fix a bug, rename a function, or add a feature, and most of the time it was not handed a tool that can change a file. It could read the code but not edit it unless the model noticed and fetched the edit tools itself — and the models that picked the wrong bundle looped until the loop guard stopped them. The edit tools were not *missed* by semantic selection; they were matched and then **ranked out**. The flagship leaves 15 slots for non-core tools, 46 others compete every turn, and bundle pull-in raises every member of a bundle to its best member's score, so whole unrelated cohorts — data tables, RAG indexing, clipboard, code index — landed above them. On seven explicit edit prompts the edit tools made the loaded set twice. Scores on these prompts are too close together (edit tools 0.24–0.38, winners 0.35–0.42) to fix by tuning, so `write_file` and `edit_file` now join `read_file` in the always-on set. **Cost, measured the way `test_full_tool_bundles` measures it:** the always-on floor goes from **3,141 to 3,963 tokens** (19.2% → 24.2% of the full registry; the guard is 30%). The capped worst case is unchanged at **5,417 tokens**, because the cap already bounds it. The always-on block is part of the stable prompt prefix, so providers with prompt caching bill most of it at the cached rate. Closes amd#3752 ## Test plan - [x] Selector re-run against this branch — edit tools are in the loaded set on every edit prompt that previously dropped them (numbers in the thread). - [x] `pytest hub/agents/gaia/python/tests/test_full_tool_bundles.py tests/unit/test_chat_tool_bundles.py tests/unit/test_chat_dynamic_tools.py tests/unit/test_tool_loader_disambiguation.py` — full-profile coverage, cap and token-budget guards pass. - [x] 6 local failures are pre-existing and unrelated: identical on `origin/main`, with **byte-identical numbers** with and without this change — 2 need `search_documentation` (npx), 4 are doc-profile token pins, and the doc profile is untouched here. - [ ] `gaia eval agent` — required by CLAUDE.md for tool-registration changes. - [x] Benchmark A/B, the same battery before and after: coding tasks finished with zero file edits in 18/48 runs before and 9/54 after; `load_tools` calls 165 → 123. The first after-run was confounded by an unrelated history regression (amd#3758), so these numbers come from the re-run with that fixed. --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]>
…ends Merging main broke three of this PR's tests without touching its fix. amd#3997 replaced the text flattening they were written against: a tool-call turn now keeps its native tool_calls with `content: None`, and a tool result is a `role: "tool"` message instead of `[Tool result: …]` user text. The one-line guard this PR exists for is still load-bearing — a `tool` turn or a plain turn carrying `content: None` still stringified to the word "None", which is what a model started echoing back. The tests now pin that case directly and keep the native-shape assertions that amd#3997 made true.
GAIA can now answer follow-ups using prior tool evidence in the TUI, including after reopening its transcript. Previously the saved conversation could retain only the final prose, losing facts the tools had read. Complete turns are archived locally and replayed within a budget that reserves room for the current prompt, tools, and answer. Closes #3628. Depends on #3669 (included here); also includes the SDK null-content normalization from #3758 with original authorship. <details> <summary>🔍 Technical details</summary> The TUI stores its transcript under `GAIA_TUI_HOME/history/`; `--history-file` or `GAIA_HISTORY_FILE` reopens an explicit transcript. Whole tool groups stay intact when older turns leave the active window. Persistence completes before the terminal response, and clearing the history deletes its archive. Legacy chat persistence uses the same budget calculation. </details> ## Test plan - [x] 219 integrated configuration, SDK, history, and stdio tests passed; 106 history/stdio tests passed after the final error-handler cleanup. - [x] CI runs the history/stdio regression coverage and context-resolution tests. - [x] Real TUI with local Gemma-4-E4B and memory disabled: read a file, omit its facts from the final answer, delete the file, then recover its code in a follow-up without a tool call. - [x] Restart the TUI with the same transcript and recover ledger number `7319`, which appeared only in the deleted file's tool result. - [ ] Formal agent quality evaluation and human review. One initial live follow-up hit a backend timeout; the retry and restart checks passed. These checks establish evidence retention, not a latency or quality benchmark. --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Tomasz Iniewicz <[email protected]>
On every non-Claude backend (local Lemonade models, and Fireworks through Lemonade), GAIA replayed each tool-call turn to the model as an assistant message saying "None". minimax-m3 copied that, replied "None" on coding tasks, and GAIA handed "None" to the user as the final answer. A
Noneturn is now an empty string. The Claude path, which already sends native tool calls, is unchanged.An earlier version of this PR replayed each call as
[Tool call: name(args)]text instead. That was wrong. The same 144-run benchmark showed models copying the text format instead of calling tools. The parser rejected those calls, and 58 runs ended in "I had trouble formatting my tool call" (0 before). That rendering is removed. The PR is now a two-line guard plus tests that pin both failure modes.Closes #3757
Test plan
pytest tests/unit/test_sdk_history_tool_calls.py: a tool-call turn becomes neither "None" nor imitable text; accompanying text is kept verbatim; tool results still name the tool; the Claude path still sends native calls.pytest tests/unit/test_sdk_tool_messages.py tests/unit/test_claude_provider.py tests/unit/test_turn_metrics_wire.py: 82 pass.gaia eval agent: required by CLAUDE.md, because this changes what the model is sent.