You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compaction.auto: false is ignored when provider throws a context overflow error #16882
Setting compaction: { "auto": false } prevents proactive compaction (the token threshold check), but compaction still runs when the provider returns a hard context overflow error. The auto: false flag is completely ignored in this path.
The catch block for ContextOverflowError in processor.ts bypasses isOverflow() entirely and schedules compaction unconditionally. Once scheduled, the compaction task marker is written into the session message stream and SessionCompaction.process() runs on every subsequent loop iteration regardless of config.
The practical consequence: when a session hits the context limit, stopping and switching to a model with a higher token limit has no effect. The session remains stuck in the compaction task. The only escape is starting a new session entirely or manually changing the session json and removing the error entirely.
Reverting the last message is not an option as the agent would lose track of file edits already made in the session
Plugins
None
OpenCode version
1.2.24
Steps to reproduce
Set compaction: { "auto": false } in opencode.json
Run a session until the provider returns a context overflow error (this triggers the auto compaction task)
(optional)
Stop the session and switch to a model with a higher context limit
Resume - the session is stuck in the compaction task
this looks like a clear config-consistency bug in the overflow path.
suggested fix:
in the ContextOverflowError catch path, apply the same compaction.auto gate used by proactive overflow checks (isOverflow() path)
if compaction.auto === false, do not enqueue a compaction task marker; surface a recoverable error instead
on resume / model-switch, clear any stale queued compaction marker when auto compaction is disabled (or when current model context no longer overflows)
right now the session can get trapped in a compaction loop, and switching to a higher-context model doesn’t recover because the queued task keeps re-running.
expected behavior: auto:false should consistently mean no automatic compaction, regardless of whether overflow is predicted proactively or returned by provider error.
packages/opencode/src/session/processor.ts,lines356-364inthediff:
// Before (fell through to error → stop):if(MessageV2.ContextOverflowError.isInstance(error)){// TODO: Handle context overflow error}// After (forces compaction, skips error path):if(MessageV2.ContextOverflowError.isInstance(error)){needsCompaction=true// line 360Bus.publish(Session.Event.Error,{sessionID: input.sessionID,
error,})}else{Theelseonline365isthebug—overflownolongerreachesinput.assistantMessage.error=error(line379),sothesessionneverstops.
When auto: false: treat ContextOverflowError as a normal error → set assistantMessage.error → return "stop". No compaction marker is written. Session stops cleanly. User can resume the same session with a bigger model.
When auto: true (default): keep current behavior — needsCompaction = true → compacts and recovers. PR #14707's fix stays intact for the majority of users.
Opened PR #17936 with a fix for this. The change adds a compaction.auto === false gate to the ContextOverflowError catch block in processor.ts so the session stops cleanly instead of being forced into compaction.
So far, none of these seem to have landed as a complete fix, and they appear to cover different parts of the same failure mode rather than being exact duplicates.
Would it make sense to consolidate the useful parts into a single PR against the current dev branch? I'd be happy to put one together if that would be useful.
So far, none of these seem to have landed as a complete fix, and they appear to cover different parts of the same failure mode rather than being exact duplicates.
Would it make sense to consolidate the useful parts into a single PR against the current dev branch? I'd be happy to put one together if that would be useful.
Thanks for clarifying — that makes sense for the specific scope of this issue.
For the compaction.auto: false path reported here, #30749 does look like the relevant fix.
I was separating that from the remaining auto-enabled loop case, where auto-compaction is allowed but keeps running because compaction does not reduce tokens enough. That seems better tracked by #28543 / #30680 and the stalled-compaction approach in #29150.
So for this issue's original auto: false case, #30749 seems to cover it.
Activity
MaheshBhushan commentedon Mar 10, 2026
this looks like a clear config-consistency bug in the overflow path.
suggested fix:
right now the session can get trapped in a compaction loop, and switching to a higher-context model doesn’t recover because the queued task keeps re-running.
expected behavior: auto:false should consistently mean no automatic compaction, regardless of whether overflow is predicted proactively or returned by provider error.
timwkosatec commentedon Mar 10, 2026
Found the PR where the auto flag was overlooked:
timwkosatec commentedon Mar 10, 2026
Proposed Design:
When auto: false: treat ContextOverflowError as a normal error → set assistantMessage.error → return "stop". No compaction marker is written. Session stops cleanly. User can resume the same session with a bigger model.
When auto: true (default): keep current behavior — needsCompaction = true → compacts and recovers. PR #14707's fix stays intact for the majority of users.
timwkosatec commentedon Mar 18, 2026
Opened PR #17936 with a fix for this. The change adds a
compaction.auto === falsegate to theContextOverflowErrorcatch block inprocessor.tsso the session stops cleanly instead of being forced into compaction.one-pyy commentedon Apr 25, 2026
The PR is taking a long time to be merged. Perhaps you could configure the model as follows:
danielxxomg commentedon Jun 5, 2026
I was looking into the recent compaction-loop reports, and this issue seems like the best place to keep the related context together.
From tracing the current code and the related PRs, it looks like there are a few separate pieces involved:
compaction.auto === falsepath forContextOverflowError, but it was closed without merge and is now stale.So far, none of these seem to have landed as a complete fix, and they appear to cover different parts of the same failure mode rather than being exact duplicates.
Would it make sense to consolidate the useful parts into a single PR against the current dev branch? I'd be happy to put one together if that would be useful.
timwkosatec commentedon Jun 5, 2026
#30749
Nexxeln already made yesterday a merge, his merge is related to the problem we had, so this issue can be closed
danielxxomg commentedon Jun 5, 2026
Thanks for clarifying — that makes sense for the specific scope of this issue.
For the
compaction.auto: falsepath reported here, #30749 does look like the relevant fix.I was separating that from the remaining auto-enabled loop case, where auto-compaction is allowed but keeps running because compaction does not reduce tokens enough. That seems better tracked by #28543 / #30680 and the stalled-compaction approach in #29150.
So for this issue's original auto: false case, #30749 seems to cover it.