Skip to content

fix(models): use 1M context for openai-codex gpt-5.4#37876

Merged
jalehman merged 3 commits intoopenclaw:mainfrom
yuweuii:codex/openai-codex-gpt54-1m-context
Mar 9, 2026
Merged

fix(models): use 1M context for openai-codex gpt-5.4#37876
jalehman merged 3 commits intoopenclaw:mainfrom
yuweuii:codex/openai-codex-gpt54-1m-context

Conversation

@yuweuii
Copy link
Contributor

@yuweuii yuweuii commented Mar 6, 2026

Summary

This fixes the openai-codex/gpt-5.4 forward-compat fallback so it no longer inherits the legacy Codex context window from gpt-5.3-codex / gpt-5.2-codex templates.

Instead, the fallback now explicitly uses GPT-5.4 metadata for:

  • contextWindow = 1_050_000
  • maxTokens = 128_000

This also updates the compat/list test expectations so the local model catalog and forward-compat resolution stay aligned.

Closes #37875.

Testing

  • pnpm vitest run src/agents/model-compat.test.ts src/agents/pi-embedded-runner/model.test.ts src/commands/models/list.list-command.forward-compat.test.ts
  • pnpm build

@openclaw-barnacle openclaw-barnacle bot added commands Command implementations agents Agent runtime and tooling size: XS labels Mar 6, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR fixes a forward-compatibility bug where openai-codex/gpt-5.4 was incorrectly inheriting the legacy 272 K context window from the gpt-5.3-codex / gpt-5.2-codex templates instead of using GPT-5.4's own 1 M context window. The fix is clean and well-targeted.

Changes:

  • model-forward-compat.ts: Adds OPENAI_CODEX_GPT_54_CONTEXT_TOKENS = 1_050_000 and OPENAI_CODEX_GPT_54_MAX_TOKENS = 128_000 constants, and introduces a patch object that is spread over the cloned template (and also drives the no-template fallback path) only for the gpt-5.4 case. Spreading undefined in the non-5.4 branches is a valid JS/TS no-op, so gpt-5.3-codex behavior is unchanged.
  • model-compat.test.ts, model.test-harness.ts, list.list-command.forward-compat.test.ts: Test expectations updated from 272_000 to 1_050_000 to match the corrected metadata.

No logic errors or regressions were found. The change is minimal and surgical—two new constants plus a three-property patch object—with all affected code paths covered by updated unit tests.

Confidence Score: 5/5

  • This PR is safe to merge — it is a narrow, well-tested metadata correction with no functional side-effects on other model resolvers.
  • The change is minimal and surgical: two new constants + a three-property patch object. All affected code paths are covered by updated unit tests. No existing behavior for other model IDs (gpt-5.3-codex, gpt-5.2-codex) is altered. The patch approach elegantly uses falsy checks (patch?.contextWindow ?? DEFAULT_CONTEXT_TOKENS) to ensure both template and fallback code paths work correctly.
  • No files require special attention.

Last reviewed commit: 0d21607

@jalehman jalehman self-assigned this Mar 8, 2026
@jalehman jalehman force-pushed the codex/openai-codex-gpt54-1m-context branch from 0d21607 to b507ebe Compare March 8, 2026 18:00
@openclaw-barnacle openclaw-barnacle bot added the cli CLI command changes label Mar 8, 2026
@jalehman jalehman force-pushed the codex/openai-codex-gpt54-1m-context branch from b507ebe to 9891440 Compare March 8, 2026 18:04
@openclaw-barnacle openclaw-barnacle bot removed the cli CLI command changes label Mar 8, 2026
@jalehman jalehman force-pushed the codex/openai-codex-gpt54-1m-context branch from 9891440 to 3f36f59 Compare March 8, 2026 18:57
@openclaw-barnacle openclaw-barnacle bot added the cli CLI command changes label Mar 8, 2026
@jalehman jalehman force-pushed the codex/openai-codex-gpt54-1m-context branch 3 times, most recently from a8ea9a5 to bb77c55 Compare March 9, 2026 01:20
@jalehman jalehman force-pushed the codex/openai-codex-gpt54-1m-context branch from bb77c55 to c410207 Compare March 9, 2026 01:23
@jalehman jalehman merged commit f624391 into openclaw:main Mar 9, 2026
23 of 26 checks passed
@jalehman
Copy link
Contributor

jalehman commented Mar 9, 2026

Merged via squash.

Thanks @yuweuii!

GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
Merged via squash.

Prepared head SHA: c410207
Co-authored-by: yuweuii <82372187+yuweuii@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
vincentkoc pushed a commit that referenced this pull request Mar 9, 2026
Merged via squash.

Prepared head SHA: c410207
Co-authored-by: yuweuii <82372187+yuweuii@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
Merged via squash.

Prepared head SHA: c410207
Co-authored-by: yuweuii <82372187+yuweuii@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai-codex/gpt-5.4 forward-compat fallback still uses 272k context

2 participants