Repository navigation
Studio: compact long chats on API models too - #12786
Conversation
The item only reached the client as a tool event, so every later round of the same turn resent the uncompacted history and the provider compacted it again. The loop now replays it after the messages it covers on each later request.
… that fit Retrieved passages and tool results grow the prompt after the route fitted it, so the transport fits each request again, without the saved-transcript boundary. The reply cap is only lowered when the prompt plus the cap would overflow the window.
|
Pushed two follow-up commits after reviewing and live-testing this branch. What changed
Tested
Known and left out to keep this small
|
…ction The retry after `compact_threshold is not enabled` only dropped context_management and resent the whole history, so such a deployment got neither compaction nor trimming. The retry now sends the locally fitted history and reply cap.
previous_response_id and the image replay items gathered before the compaction item stayed set, so the request mixed stateless compaction replay with response chaining.
|
Follow-up on the changes pushed above: the head Codex review: converged on CI on the same head: 60 passed, 2 failed, 4 skipped. Neither failure comes from this PR:
What changed during this round:
Raised in review and left out to keep this PR small:
Each of these behaves the same as it does without this PR, so none is a regression. |
Review and verification evidenceReviewed and repaired source head
The contributor's later image-chain fix and updated-main reconciliation were retained. One additional review suggestion was rejected because a positive tool-call boundary makes that turn ineligible for continuation by construction; the continuation gate regression pins that behavior. The comment/docstring cleanup remained AST-equivalent. Functional verification
Review convergenceCodex reviewed the exact tree at mirror commit UI evidenceExpected: the merge base says older messages were dropped and reports Observed on both isolated exact-tree Studio builds: provider-summarized Full baseline image | Full repaired image | Evidence branch The refreshed UI run used isolated full Studio installs on Linux x86_64 with Chrome for Testing 153.0.8010.12, a 1440x900 viewport, and device scale factor 1.5. The photographed refs are source merge base |
|
Pushed three small commits on top of What changed
How it was tested
Not covered: Anthropic and OpenAI server-side compaction have unit coverage only here; no keys for those providers were available for a live run. Seen in review and left as is: Anthropic compaction tokens are folded into |
|
The current head Codex review: converged on CI on the same head: 60 passed, 2 failed, 4 skipped. Neither failure comes from this PR, and both fail the same way without it:
Changed since the previous update
Live check of Anthropic server-side compaction Run through Unsloth Studio with Claude Sonnet 4.6 reached over OpenRouter's Anthropic-shaped endpoint, on a 60k-token chat with a 50k threshold:
OpenAI server-side compaction still has unit coverage only: OpenRouter accepts |
Lyxot
left a comment
There was a problem hiding this comment.
Reviewed and tested locally and live. Local trimming works against OpenRouter, and Anthropic server-side compaction works end to end with Claude Sonnet 4.6, including the tool loop. Codex found no major issues on this head, and the two failing checks come from main, not this PR.


Auto-compact only applied to local GGUF and MLX chats. A long chat with an API model kept sending every turn until the provider refused it with a "maximum context length" error, even with Auto-compact on.
With Auto-compact on, Claude models that support compaction and OpenAI models now summarize older turns on the provider side at three quarters of the model's window, capped at 200k tokens. The summary is saved with the reply and sent back on later turns. Other API models drop their oldest complete turns before the request goes out, leaving room for the full Max Tokens reply in the window. If Max Tokens would leave almost no room, it is lowered for that request so recent turns still fit. The existing notice and toast say when a chat was compacted.
With Auto-compact off, requests are exactly as before.