Skip to content

Digest stale tool results before the next model turn - #383

Draft
tylerreckart wants to merge 1 commit into
mainfrom
cursor/tool-result-elision-4d79
Draft

tylerreckart wants to merge 1 commit into
mainfrom
cursor/tool-result-elision-4d79

Conversation

@tylerreckart

Copy link
Copy Markdown
Owner

Summary

Every tool batch was resent in full on later turns until compaction, so a few /read and /exec results crowded the prompt the model was trying to think with. The model view now keeps the newest tool batch intact and replaces older bulky envelopes with a digest: the writ line, ok, N bytes omitted or the first ERR: line, plus any presence note or loop warning. Results under 4 KB stay whole. Stored history and replay are unchanged.

Compaction also treats a live [END TOOL RESULTS] envelope as a tool re-entry when choosing the kept tail (those envelopes do not start with the [TOOL RESULTS] prefix). The summarize call uses the same digest, so that extra model call is no longer a second copy of every file body.

Set ARBITER_TOOL_ELIDE_DISABLED=1 to send every body.

Test plan

  • unit_context_compaction — 35 cases, including digest vs newest-batch, image drop, line-start ERR: only, live-envelope cut, and the disable env var
  • A multi-step tool loop in the TUI: the second model turn still sees the latest tool output, and an earlier large /read shows up as a one-line digest
Open in Web Open in Cursor 

The model view keeps the newest tool batch in full and replaces older
bulky envelopes with the writ, an ok/ERR status, and any presence note
or loop warning. Stored history is unchanged. Compaction now recognizes
live tool envelopes when choosing the kept tail, and the summarize call
uses the same digest.

Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
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.

2 participants