Skip to content

fix: count tool call arguments in the compaction tail budget - #258

Open
liuzhengyang699 wants to merge 1 commit into
HKUDS:mainfrom
liuzhengyang699:fix/compaction-tool-call-budget
Open

liuzhengyang699 wants to merge 1 commit into
HKUDS:mainfrom
liuzhengyang699:fix/compaction-tool-call-budget

Conversation

@liuzhengyang699

Copy link
Copy Markdown

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.py and tests/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 and git diff --check passed on the changed files.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant