Repository navigation
fix: count tool call arguments in the compaction tail budget - #258
Conversation
|
Merged in a6a7949. Thank you for the fix, @liuzhengyang699. Checked against main before merging:
A related gap outside this PR: the runner's shrink gate, |
…rinkage /compact refuses a summary that does not shrink the history, but the check counted message content only. In a coding session most of the volume is tool-call arguments (a write_file call carries the whole file), so a real session with one 11,142-byte write and two short explanations measured 2,539 characters, and any summary over about 1,000 characters was refused as "would not shrink". The report the TUI prints had the same blind spot and announced "~-267 chars ... replaced". Both now use compaction's message_chars, which #258 introduced for the tail budget: content plus the serialized tool calls. On DeepSeek the same session now compacts 9 -> 3 messages and reports about 11,500 characters replaced.
|
A follow-up on the related gap I mentioned: a real session hit it right after the merge. One 11 KB |
Compaction counts only message content when deciding which history fits in the retained tail. Assistant tool calls commonly have empty content but large arguments, so an old file-writing call can be retained as if it consumed no context.
Include the serialized tool calls in the character estimate, as the runtime token estimator already does. The current-user-turn retention rule and tool-call pairing still apply.
Validation: 9 tests passed across
tests/test_compaction_tool_call_budget.pyandtests/test_session_compaction.py. The new old-call regression fails before the fix; a second case verifies that a large call in the active turn keeps its matching tool result. Ruff 0.15.21 check/format andgit diff --checkpassed on the changed files.