Skip to content

GPT 5.5 context limits are not respected #24751

@asaf-genie

Description

@asaf-genie

Description

opencode uses hard coded context limits values for gpt-5.5, ignoring values set in opencode.jsonc.

I suspect it's due to PR #24212 which added this to codex.ts:

// gpt-5.5 models temporarily have restricted context window size for codex plans
if (model.id.includes("gpt-5.5")) {
  model.limit = {
    context: 400_000,
    //@ts-expect-error incorrect type for v1 sdk but works
    input: 272_000,
    output: 128_000,
  }
}

It should probably either overwrite only when the values are not specified in the config, or use max(400_000, model.limit.context) (same for input/output) to allow lower values (which is useful because gpt-5.5 is very expensive)

Plugins

None

OpenCode version

1.14.28

Steps to reproduce

  1. Add this to ~/.config/opencode/opencode.jsonc in provider.openai.models:
"gpt-5.4": {
  "limit": {
    "context": 200000,
    "input": 150000,
    "output": 50000,
  },
},
"gpt-5.5": {
  "limit": {
    "context": 200000,
    "input": 150000,
    "output": 50000,
  },
},
  1. Run opencode models openai --verbose and check context limits for both models. gpt-5.4 will respect the overrides, gpt-5.5 will not. Alternatively, start a conversation with gpt-5.5, you'll see that the context window stats are relative to 400k context window not 200k.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions