Skip to content

tui: compaction triggers around 30–35% with gpt-5.6-sol #38851

Closed as not planned

Description

@magoz

Summary

In the TUI, automatic compaction consistently triggers when the context indicator reaches only
approximately 30–35% while using openai/gpt-5.6-sol. This causes sessions to be
compacted while most of the reported context window remains available.

Environment

  • opencode version: v0.0.0-next-16197
  • OS: Darwin 25.4.0, arm64
  • Terminal: tmux (TERM=xterm-256color, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: OpenCode 2 beta/next
  • Active plugins: none
  • Model: openai/gpt-5.6-sol

Reproduction

  1. Launch the OpenCode 2 beta TUI with openai/gpt-5.6-sol as the active model.
  2. Continue working in a session until the TUI context indicator reaches approximately 30–35%.
  3. Observe that automatic compaction starts at that point.

Expected Behavior

Compaction should occur only when the session approaches the model's usable context
limit. A context indicator showing 30–35% should not cause automatic compaction unless
the displayed percentage or configured model limit is incorrect.

Actual Behavior

Automatic compaction consistently starts around 30–35% reported context usage in the TUI.

Additional Context

The behavior is consistent with openai/gpt-5.6-sol. Other models have not been tested.
No exact error is shown, and no workaround has been identified.

Activity

  1. changed the title [-]compaction: triggers around 30–35% context usage with gpt-5.6-sol[/-] [+]tui: compaction triggers around 30–35% with gpt-5.6-sol[/+] on Jul 25, 2026
  2. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to existing issues. Please check:

  3. magoz commented on Jul 29, 2026

    @magoz
    Author

    Root cause confirmed and fix opened: #39541.

    Diagnostics from a read-only DB backup:

    • 19 completed automatic compactions in the affected GPT-5.6 Sol session
    • 17/19 occurred while the TUI showed 33–36%
    • those turns consistently reported ~370k–375k tokens immediately before compaction
    • active connection was OpenAI chatgpt-browser OAuth

    This fingerprints the ChatGPT Codex backend's ~372k GPT-5.6 input ceiling. V1 already overrides OAuth GPT-5.6 to 500k context / 372k input / 128k output; V2 omitted that transform and advertised Models.dev's public API limits (1.05M / 922k / 128k). The provider therefore overflowed near 372k, V2 correctly ran overflow-recovery compaction, and the TUI divided usage by the stale 1.05M catalog limit: ~35.4%.

    #32119 only changes that display to ~40% (372k / 922k), so it does not explain or fix this case. #35863 is adjacent, but this is specifically credential-dependent catalog metadata.

    The PR ports V1's OAuth limits into V2, leaves API-key users unchanged, reloads limits when connection changes, and avoids refreshing credentials during catalog inspection. Full core suite: 1081 pass; monorepo typecheck: 30 packages.

    Separate secondary finding: V2 preflight estimates JSON.stringify(request).length / 4; two outlier compactions at 5.6% and 21.7% likely come from that heuristic. That should be tracked separately from this reproducible 35% OAuth ceiling.

  4. magoz commented on Jul 29, 2026

    @magoz
    Author

    Correction: #38987 is the existing maintainer-requested comprehensive fix and targets the actual v2 branch. It covers the credential-specific Codex catalog, preserves input limits through model resolution, budgets compaction against the input window, and fixes TUI reporting. I closed my narrower duplicate #39541 and added the empirical 370k–375k evidence to #38987.

  5. magoz commented on Jul 29, 2026

    @magoz
    Author

    Current clean fix: #39545. This supersedes stale/conflicting #38987 with the same Kit-authored implementation rebased onto latest v2; focused tests and all 33 monorepo typechecks pass.

  6. CoderTom314 commented on Jul 29, 2026

    @CoderTom314

    Using a custom provider model with context max set to 500k , i am facing repeated reproducible scenarios that a single prompt ask it to read a lot of long files, upon reading multiple files with context filling up to around 50%, it auto compacts, which should be abnormal. Is this related? any fix?
    opencode v 1.18.8

  7. github-actions commented on Sep 28, 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

No one assigned

    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