Skip to content

Compaction occurs way before context limit reached on GPT 5.4 #16333

Closed

Description

@GrahamCampbell

Description

GPT 5.4 supports a ~1M context size, however compaction is occurring way before this, similar to the levels at 5.2.

Plugins

No response

OpenCode version

1.2.20

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS 26.3.1

Terminal

No response

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:

    If your issue is already covered by one of the above, please consider closing this one and adding a "+1" or comment there instead.

  3. christallire commented on Mar 6, 2026

    @christallire

    @msadiks gpt 5.4 needs little more love here <3 thanks!

  4. msadiks commented on Mar 6, 2026

    @msadiks
    Contributor

    @christallire @GrahamCampbell
    Adding the model to allowance list is not related to compaction and the model context window config in models.dev was also correct the last time I checked it. The issue is probably the compaction logic doesn't respect the context window or might be a calculation error. I may take another look at this when I am home.

  5. oddko commented on Mar 6, 2026

    @oddko

    I think the feature (extended context window) is also opt-in/beta-ish in the first-party Codex app and burns 2X usage beyond the 272K limit. So by default you'll get hit by compaction when reaching 272K, regardless of which software you use.

    If you can implement this I'd also be interested in the fast mode ("/fast" in Codex CLI/App) toggle/config if you can.

  6. GrahamCampbell commented on Mar 6, 2026

    @GrahamCampbell
    ContributorAuthor

    I wonder if the usage-API bypasses that limit. Their documentation there says 1.05M and doesn't say any special headers or config is needed... though that could just be crappy docs.

  7. oddko commented on Mar 6, 2026

    @oddko

    On Codex (apps) it requires modifying ~/.codex/config.toml so perhaps yeah somewhat undocumented stuff, but just like the fast mode it's probably sent through the headers.

  8. msadiks commented on Mar 6, 2026

    @msadiks
    Contributor

    As I reviewed the compaction logic, it basically limits the compaction window to model input limit minus reserved limit to be able to get a summary of the history. The problem with Openai oAuth provider is that it has an input window of 272k and a context window of 1m.

    So to actually use 1m context window the options I can think of are:

    1. disable the compaction entirely.
    2. use gpt-5.4 from another provider (like from opencode zen with 900k input window)
    3. refactor the compaction logic to use another strategy.
    4. configure the current compaction logic to use compacting agent input limits instead of current agent limits and set a compact agent with a larger input limit. considering the input limit of current agent since the summary goes there.

    In my opinion, first option wouldn't be beneficial at all. Third and fourth options are long term and need a deeper analysis. Best short term solution here is either going with second option or using the model as it is.

    I am not a maintainer of the repo so this answer is based on a quick review of the codebase.

  9. JSCOP commented on Mar 10, 2026

    @JSCOP

    This is codex configuration setup

    model_reasoning_effort = "xhigh"
    model_context_window = 1050000
    model_auto_compact_token_limit = 900000
    approval_policy = "never"
    sandbox_mode = "danger-full-access"
    personality = "pragmatic"
    service_tier = "fast"
    

    This configuration setup makes context window to 1.05M (This is experimental feature but It works)
    I think opencode need to setup this configuration internally or change model loading features to load from outside configuration file for setup all other models.

  10. rekram1-node commented on Mar 10, 2026

    @rekram1-node
    Collaborator

    This should be fixed if u run opencode models --refresh

  11. oddko commented on Mar 11, 2026

    @oddko

    Looks like it's working, thanks a lot !
    Image

  12. JSCOP commented on Mar 11, 2026

    @JSCOP

    This should be fixed if u run opencode models --refresh

    This works! thanks :)

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything 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