Skip to content

How to enable 1M context in OpenCode for GPT-5.4? Compaction triggers at 272k, not 1M #16308

Closed

Description

@InCerryGit

Question

I see that OpenAI (e.g., GPT-5.4 or Claude 3.5) officially advertises 1M context window support, but when using these models in OpenCode, compaction is triggered as soon as the session approaches 272k tokens (sometimes even earlier), and the context never comes close to the full 1M tokens advertised.

My compaction config is:

  "compaction": {
    "auto": true,
    "prune": true,
    "reserved": 16000
  }

Based on the documentation and codebase, it seems overflow/compaction is triggered using the provider/model's limit.input minus the reserved buffer. Here are my questions:

  1. Does OpenCode actually support the new 1M-token context for GPT-�3 or GPT-5.4? Or is it possible that the provider/model metadata is still set to the legacy window size?
  2. Is there a way to explicitly configure or pass model_context_window / model_auto_compact_token_limit (or similar params) in opencode to activate or test the real 1M window?
  3. Are there any best practices, config tweaks, or workarounds to enable the extended context and prevent premature compaction at ~272k?
  4. If true 1M context support is not yet possible, what is the recommended solution to make full use of the model's real window size?

Any guidance or clarification would be greatly appreciated!

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 6, 2026
  2. github-actions commented on Mar 6, 2026

    @github-actions
    Contributor

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

    Please review those issues and consider adding your information there rather than opening a new one.

  3. TomLucidor commented on Mar 9, 2026

    @TomLucidor

    Similar issues here where the defaults are all wrong #16709

  4. MartyMcFlyInTheSky commented on Apr 21, 2026

    @MartyMcFlyInTheSky

    Same here. In general options to control the context window are dearly lacking.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions