Repository navigation
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Until this PR (or some other fix) is merged, a simple workaround can help: select a different model which has a larger context window than the current one. Then compression will work. After the successful compression, the original model can be used again to continue the work. |
…ntext When the serialized conversation head no longer fits the model's usable context, compaction gave up with "Session too large to compact" and the session became unusable. Shrink the head from the oldest complete turns instead so the summarizer request fits the model context. Assisted-by: OpenCode / qwen3.8-27b-thinking (Alibaba Cloud) Signed-off-by: Stefan Weil <[email protected]>
9102cbc to
36a9384
Compare
|
Reviewed against a live reproduction on opencode 1.18.32 (stable). Environment: provider Reproduction. Auto-compaction fired at a 666,763-token live context and the summarizer call was rejected: Mechanism (both steps verified).
The approach is right. Dropping oldest complete turns bounds the head. On my session the head was ~1.03M tokens while the newest single turn was only ~43k, so the head, not the tail, is where the budget was missing. Three gaps worth closing before merge:
Style nit per CONTRIBUTING: prefer an immutable local over Settings that mitigate until this lands ( Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system) |
… params (#251) The umbrella opencode config kept the models.dev generation default and the stock compaction tail budget. On a long session that combination wedges: select() budgets only the retained tail, whose default is min(15000, ...), so once the newest turn exceeds it the summarizer head becomes the ENTIRE serialized history (all reasoning text retained, tool output capped at 2k). Measured on session ses_f31022a99ffe1gLJ1RdyDnhlAh (opencode 1.18.32, ollama-cloud/deepseek-v4.1-flash, 1048576 context): - auto-compaction fired at a 666,763-token live context; - the summarizer prompt was 1,122,556 input tokens (logged) — reconstructing the head with the exact serialize() rules and measuring it through the real provider gives 1,128,448 (0.5% apart); - the provider rejected it ("The prompt is too long"), the session was wedged. The provider admits on INPUT tokens only (probed: 800k prompt + 393216 max_tokens accepted; 1.05M prompt rejected), so reserved/max_tokens do not size the request — the head does. Changes: - compaction.preserve_recent_tokens: 500000 — keeps a large verbatim tail so the summarized head shrinks. Reconstructed head drops from 1,128,448 to 634,064 real tokens. Stopgap until opencode drops oldest turns itself (anomalyco/opencode#48844, PR #51121). - model options: max_tokens 262144, reasoningEffort high, and the sampling set (temperature 1.0, top_p 0.95, frequency_penalty 0.5, presence_penalty 1.0) — exact parity with the org PR-eval engine and the vendor-recommended sampling for deepseek-v4.1-flash. Upstream: anomalyco/opencode#48844 (open) and anomalyco/opencode#51121 (open, "drop oldest turns when compaction head exceeds model context"). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
When the serialized conversation head no longer fits the model's usable context, compaction gave up with "Session too large to compact" and the session became unusable. Shrink the head from the oldest complete turns instead so the summarizer request fits the model context.
Assisted-by: OpenCode / qwen3.8-27b-thinking (Alibaba Cloud)
Issue for this PR
Fixes #29857, #48844 and maybe some more
Type of change
What does this PR do?
When the serialized conversation head no longer fits the model's usable context, compaction gave up with "Session too large to compact" and the session became unusable. Shrink the head from the oldest complete turns instead so the summarizer request fits the model context.
How did you verify your code works?
Tested in local work.
Screenshots / recordings
No UI change.
Checklist