Repository navigation
fix(memory): store large tool args as valid JSON so tool history stays readable - #3754
Conversation
…ep their edits Every file edit the agent made was saved to memory with its arguments destroyed. log_tool_call capped args at 500 characters by cutting the serialized JSON text, so any write_file or edit_file carrying real file content was stored mid-token and could never parse again. The reader logged "corrupt JSON column value ignored" and returned None. Measured on a benchmark memory store: 72 of 499 tool calls (14%) were unreadable, all write_file or edit_file, all exactly 500 characters. The only reader is skill synthesis, so every skill GAIA learned from a coding session recorded "call edit_file" with no file and no change. The cap stays; long string values are shortened instead of the text being cut, so short fields like file_path survive and the stored value always parses. Arguments too wide to shorten fall back to their names. Closes amd#3753 Co-Authored-By: Claude Opus 5 <[email protected]>
|
Verdict: Approve with suggestions This replaces a byte-cut of the serialized tool-call arguments with a value-level shrink, so what gets stored in tool history always parses back and short fields like the file path survive. The change is sound, the cap is preserved, and the new tests cover the interesting shapes — I re-ran the helper against extra shapes myself and every result parsed and stayed under the limit. One thing worth knowing before merge: the stated payoff — learned skills keeping their edits — doesn't actually land yet. The step that turns a session into a skill throws the arguments away before the model ever sees them, keeping only the tool names, so a recipe still says "call edit_file" with no file and no change even with this fix in place. What this PR genuinely fixes today is the tool-history views, which previously showed unreadable argument blobs for every large write or edit. If closing the linked issue means recipes carry their edits, a companion change to the synthesis step is still needed. Two smaller things: a large payload nested inside a list or dict still falls all the way back to bare argument names, dropping the file path this PR set out to keep (the current file tools pass flat strings, so it doesn't bite today); and the PR description carries a "Generated with Claude Code" footer, which this repo's conventions prohibit. Real-world evidenceN/A — no evidence bundle was produced for this run, and the change is an internal storage helper with no CLI, API, MCP, or Agent UI surface of its own. The verdict rests on static review plus a local re-run of the new helper against additional argument shapes (nested containers, non-string keys, unserializable values, unicode) — all parsed and fit the cap. 🔍 Technical details🟡 ImportantStored args never reach skill synthesis, so the PR's headline outcome isn't reachable yet (
The readers that do benefit are 🟢 MinorNested payloads skip the shrink and lose The comprehension only shortens top-level
Shrunk values carry no truncation marker ( A trailing Tests exercise the private helper only ( The five cases are well chosen, but none goes through PR description carries a Claude attribution footer CLAUDE.md → "No Claude Attribution of Any Kind" prohibits the Strengths
|
…tial rows A tool call with a big list or dict argument (say, a batch of edits) still dropped straight to bare argument names in tool history, losing the file path. Nested values are now shortened like strings, and any shortened row carries the same _truncated flag as the names-only fallback, so a reader can tell a partial row from a complete one. Adds a round-trip test through log_tool_call -> get_tool_history for a large write, and narrows the docstrings: the fix is to tool-history readability; skill synthesis still keeps tool names only. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Thanks. All four points are addressed in 89359e2.
Measured on the same 144-run benchmark battery before and after this change, unreadable argument rows across every run's memory store went from 92 to 0. The attribution footer stays in the description on purpose, because the session that opened this PR is instructed to keep it. That conflicts with CLAUDE.md, so a maintainer should make the call. 🔍 Technical details
|
- Rebased onto current main (245 commits since v0.23.0, up from 230). - Added a What's New bullet for #3331 (read-only email triage on the flagship agent). - Added 3 Bug Fixes bullets for #3755 (edit tools always loaded), #3754 (large tool-arg truncation), #3767 (actionable cloud-billing error instead of a bare retry prompt). - Regenerated the Full Changelog against the new range.
The tool history saved every large file write or edit with its arguments broken, so the history views showed nothing for those calls — not even which file was touched.
The tool history capped arguments at 500 characters by cutting the serialized JSON text, so any
write_fileoredit_filecarrying real content was stored mid-token and could never parse. Measured on a benchmark memory store: 72 of 499 tool calls (14%) unreadable, every one awrite_fileoredit_file, every one exactly 500 characters. Tool history and the recent-errors views read these rows back as empty.The cap stays. Long values, nested lists and dicts included, are now shortened instead of the text being cut, so short fields like
file_pathsurvive, the stored value always parses, and a_truncatedflag marks a partial row. Arguments too wide to shorten fall back to their names.This does not yet make learned skills carry their edits: skill synthesis keeps only tool names, so that half of #3753 needs a separate change.
Refs #3753
Test plan
pytest tests/unit/test_memory_store_tool_args.py— 7 tests: small args verbatim; 100 KB file content still parses, keepsfile_pathand is flagged_truncated; an edit with two large strings keeps all three keys; a large nested list of edits is shortened and keepsfile_path; over-wide args fall back to their names; empty args store nothing; a large write round-trips throughlog_tool_call→get_tool_historywithfile_pathintact. Every stored value is asserted to be under the cap.pytest tests/unit -k "memory_store or skill_synthesis or procedural"— 421 pass, 63 skipped.