GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BUG]: Auto compaction not triggering reliably with Anthropic models · Issue #6068 · anomalyco/opencode

[BUG]: Auto compaction not triggering reliably with Anthropic models #6068

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[BUG]: Auto compaction not triggering reliably with Anthropic models#6068
Copy link
Assignees
rekram1-node

Description

@ramarivera
ramarivera
opened on Dec 23, 2025
Issue body actions

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

  1. Start a session with an Anthropic model (e.g., claude-sonnet-4-20250514)
  2. Have an extended conversation with multiple tool calls and file edits
  3. Continue working until context approaches the model's token limit (e.g., 131072 or 200000)
  4. Observe that instead of auto compaction running, you receive errors like:
    This model's maximum context length is 131072 tokens. However, you requested N tokens...
    
    or
    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

  1. Did anything change in the auto compaction logic recently?
  2. Are there any new configuration options affecting compaction behavior?
  3. Is there any way to adjust the threshold or make compaction more aggressive?

Thanks for investigating this!

Reacted by Alexander Tkachev

Activity

  1. github-actions
    assigned
    rekram1-node
    on Dec 23, 2025
  2. github-actions commented on Dec 23, 2025

    @github-actions
    github-actionsBot
    on Dec 23, 2025 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • prompt is too long #5360: prompt is too long (reports similar 'prompt is too long' errors with Anthropic)
    • prompt is too long unrecoverable #4845: prompt is too long unrecoverable (reports 'prompt is too long' errors with Opus 4.5 that are unrecoverable)
    • [FEATURE]: Allow continuation after context overflow #5178: Allow continuation after context overflow (related feature request for handling context overflow)
    • Session Todo-list is forgotten after compaction #5934: Session Todo-list is forgotten after compaction (related compaction behavior issue)
    • Auto compaction happens much earlier than expected when caching is enabled #4416: Auto compaction happens much earlier than expected when caching is enabled (related auto compaction threshold issue)

    Feel free to ignore if none of these address your specific case.

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  3. o1x3
    added a commit that references this issue on Jan 1, 2026

    fix(session): prevent context overflow by adding safety margin to com…

    This issue will close once commit 5707d22 is merged into the 'dev' branch.
    5707d22
  4. Leksat commented on Jan 5, 2026

    @Leksat
    Leksat
    on Jan 5, 2026
    More actions

    Same for me.

    I use opencode v1.1.2 connected to Claude Max plan. Right pane shows

    Context
    107,981 tokens
    54% used
    

    But get prompt is too long: 203185 tokens > 200000 maximum anyways. Confusing 😕

    Reacted by Tomas Awate
  5. github-actions commented on Mar 25, 2026

    @github-actions
    github-actionsBot
    on Mar 25, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  6. alario-tang commented on Mar 31, 2026

    @alario-tang
    alario-tang
    on Mar 31, 2026
    More actions

    I think this issue is partly about trigger timing, not only model/provider behavior.

    From reading the current code, auto-compaction seems to be driven mostly by:

    • post-step token usage crossing threshold
    • provider-side overflow / context rejection

    That means the system is still often reacting after a request was already too large, instead of shrinking context before the next risky request is sent.

    A useful improvement here may be a lightweight pre-request pass before normal generation, for example:

    • prune older completed tool output earlier
    • reserve a stricter output budget
    • compact proactively before provider rejection, not after

    That would likely reduce the “prompt too long first, compaction later” failure mode this issue describes.

  7. rekram1-node
    closed this as not plannedon May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.