Skip to content

compaction.auto: false is ignored when provider throws a context overflow error #16882

@timwkosatec

Description

@timwkosatec

Description

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

  1. Set compaction: { "auto": false } in opencode.json
  2. Run a session until the provider returns a context overflow error (this triggers the auto compaction task)
    (optional)
  3. Stop the session and switch to a model with a higher context limit
  4. Resume - the session is stuck in the compaction task

Screenshot and/or share link

No response

Operating System

Windows 11 Enterprise

Terminal

Windows Terminal

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)windows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions