Skip to content

Auto-compact infinite loop with claude-opus-4.7-1m (GitHub Copilot) due to wrong context window #28543

Closed as not planned

Description

@pushp1997

Description

Summary

When using github-copilot/claude-opus-4.7-1m (1M token context window), OpenCode reports context usage against what appears to be a ~200K denominator. Once real usage crosses ~200K, the TUI shows >100% (e.g. 236.9K (118%)) and auto-compaction fires repeatedly in a loop — compact runs, post-compact context is still "over limit" per the same wrong denominator, compact fires again. Burns Copilot tokens and blocks all work in the session.

Environment

  • OpenCode 1.14.40
  • Windows (pwsh)
  • Provider: GitHub Copilot (built-in)
  • Model: github-copilot/claude-opus-4.7-1m (1,000,000 token context)
  • Small model: github-copilot/claude-sonnet-4.6

Expected

  • OpenCode reads the actual model context window (1M for this model) and computes the percentage against it. At 236.9K usage the display should be ~24%, not 118%.
  • Auto-compact should not fire (well under threshold), and even if a model's limit is genuinely unknown, auto-compact must not re-fire immediately after a no-op compaction.

Actual

  • Context window for claude-opus-4.7-1m-internal is misread as roughly 200K.
  • Auto-compact loops indefinitely once real usage crosses that wrong threshold.

Workaround

Disable auto-compaction in ~/.config/opencode/opencode.json:
```json
{
"compaction": { "auto": false }
}
```
This breaks the loop but leaves the wrong percentage display.

Suggested fixes

  1. Map claude-opus-4.7-1m-internal (and any other *-1m-* Copilot variants) to a 1M context window in the github-copilot provider definition. Or pull the real limit from the Copilot API where possible.
  2. Add a loop guard to auto-compact: if a compaction run does not reduce token count below the threshold, do not fire again in the same session without user action.

Plugins

No response

OpenCode version

1.14.40

Steps to reproduce

  1. Configure OpenCode with model: github-copilot/claude-opus-4.7-1m.
  2. Leave compaction.auto at its default (true).
  3. Make a long conversation and let it hit auto-compaction.
  4. Use the session until real token usage exceeds ~200K (well below the model's real 1M limit).
  5. TUI shows context as e.g. 236.9K (118%).
  6. Auto-compact fires. After it completes, the percentage is still >100% against the wrong denominator, so it fires again. Loop.

Screenshot and/or share link

Image

Operating System

windows 11

Terminal

Windows Terminal

Activity

  1. github-actions commented on May 20, 2026

    @github-actions
    Contributor

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

    Your issue combines two related problems (wrong context window for Copilot's claude-opus-4.7-1m variant + the resulting compaction loop), both of which appear to have existing tracking. The most directly related are #21564 (Copilot model limits bug with proposed fix) and #15533 (compaction loop). Consider whether your report adds new information or can be addressed under those issues.

  2. pushp1997 commented on May 20, 2026

    @pushp1997
    Author

    I upgraded opencode to confirm if this has been fixed, but nope:

    Image
  3. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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