-
Notifications
You must be signed in to change notification settings - Fork 9k
Open
Description
Description
Auto compaction seems to have stopped working reliably with Anthropic models. Previously, when context tokens approached the model's limit, opencode would automatically trigger compaction to summarize the session. Now, we're getting 'prompt is too long' errors more frequently without auto compaction kicking in.
Steps To Reproduce
- Start a session with an Anthropic model (e.g., claude-sonnet-4-20250514)
- Have an extended conversation with multiple tool calls and file edits
- Continue working until context approaches the model's token limit (e.g., 131072 or 200000)
- Observe that instead of auto compaction running, you receive errors like:
or
This model's maximum context length is 131072 tokens. However, you requested N tokens...prompt is too long: X tokens > Y maximum
Expected Behavior
Opencode should automatically trigger session compaction BEFORE hitting the model's context limit, summarizing previous messages to free up context for continuing the conversation.
Actual Behavior
Auto compaction is not triggering automatically, leading to 'prompt too long' errors that stop the session. Manual compaction (via keybind) still works.
Relevant Log Output
# Running with verbose logging can provide more details:
OPENCODE_LOG=* opencode run <project>Additional Context
- OpenCode version: 1.0.191 (current)
- Operating System: macOS
- Related issue: [FEATURE]: Prompt Compression #6034 (Prompt Compression feature request)
- Recent relevant commits:
- eab177f - feat(plugin): allow compaction hook to replace prompt entirely (feat(plugin): allow compaction hook to replace prompt entirely #5907)
- 8dfef67 - [FEATURE]: Show context usage in OpenCode Desktop ([FEATURE]: Show context usage in OpenCode Desktop Context usage #5979)
Questions
- Did anything change in the auto compaction logic recently?
- Are there any new configuration options affecting compaction behavior?
- Is there any way to adjust the threshold or make compaction more aggressive?
Thanks for investigating this!
Leksat
Metadata
Metadata
Assignees
Labels
No labels