Skip to content

fix: Codex catalog honors app-server context caps - #98248

Closed
hannesrudolph wants to merge 1 commit into
openclaw:mainfrom
hannesrudolph:codex-appserver-context-metadata
Closed

hannesrudolph wants to merge 1 commit into
openclaw:mainfrom
hannesrudolph:codex-appserver-context-metadata

Conversation

@hannesrudolph

Copy link
Copy Markdown
Member

Related: #93764

What Problem This Solves

Fixes an issue where users running the Codex harness could see OpenClaw model context display and budgeting based on stale local context metadata when Codex app-server has a smaller native effective context window.

This is the OpenClaw consumer side of the fix. It consumes Codex app-server context metadata when the app-server exposes it; older Codex app-server builds keep the existing fallback catalog behavior.

Companion Codex branch: https://github.com/hannesrudolph/codex/tree/codex-model-context-metadata

Why This Change Was Made

OpenClaw already has separate contextWindow and contextTokens model fields, which is the right boundary for native model metadata versus effective runtime caps. This change keeps that split and maps Codex app-server model/list context metadata into it instead of adding a model-specific clamp or changing global provider merge semantics.

User Impact

When Codex app-server reports native/effective context metadata, OpenClaw model discovery can show and budget against the same runtime cap Codex uses internally. For GPT-5.5-style catalogs that means OpenClaw can represent 272000 native context with 258400 effective context tokens instead of continuing to imply a stale 1M runtime budget.

Evidence

  • pnpm docs:list
  • node scripts/run-vitest.mjs extensions/codex/provider.test.ts extensions/codex/src/app-server/models.test.ts
  • git diff --check

Codex companion branch proof:

  • just write-app-server-schema
  • just fmt
  • PATH="$HOME/.cargo/bin:$PATH" just test -p codex-app-server-protocol -p codex-app-server model_list

What was not tested:

  • Full OpenClaw pnpm check:changed was not run.
  • Full Codex just test was not run.
  • Live Codex app-server model/list with the new upstream fields was not tested because the companion Codex change is not merged/bundled yet.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: S maintainer Maintainer-authored PR labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 8:31 AM ET / 12:31 UTC (Revision 14).

ClawSweeper review

What this changes

The PR reads optional Codex model context metadata and maps native and effective limits into OpenClaw’s model catalog, with tests and documentation.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this is maintainer-authored, protected work with a useful remaining goal. The upstream protocol prerequisite and current-main conflict resolution remain outstanding, and the documentation still overstates override behavior.

Priority: P2
Reviewed head: af41016ef592dd8e974464563ae638ae2037ca43

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The metadata mapping is focused and useful, but protocol readiness, current-owner adaptation, and the inaccurate documentation limit merge confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: MEMBER authorship exempts ordinary contributor runtime proof, and this metadata change does not trigger authority-chain proof. The body reports tests rather than a live new-field model/list run; upstream-contract verification remains separate required merge work. No stored-data contract changes were identified.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: MEMBER authorship exempts ordinary contributor runtime proof, and this metadata change does not trigger authority-chain proof. The body reports tests rather than a live new-field model/list run; upstream-contract verification remains separate required merge work. No stored-data contract changes were identified.
Evidence reviewed 10 items Pinned introduction: The verified merge-base-to-head delta adds optional context metadata parsing, catalog projection, two test updates, and a documentation claim. The checkout is the original PR head, not a synthetic merge.
Dependency signal and validation scope: The PR explicitly consumes Codex app-server model/list fields and identifies an unmerged companion Codex branch. Its captured body reports focused tests and expressly says live model/list with the new fields was not tested. This establishes the Codex dependency gate; MEMBER authorship exempts the ordinary external-contributor proof requirement.
Personally inspected upstream wire contract: The sibling checkout was inspected directly. Model at codex-rs/app-server-protocol/src/protocol/v2/model.rs:82 has no context-window fields, and model_from_preset in codex-rs/app-server/src/models.rs does not emit them. GitHub verified this source SHA belongs to openai/codex.
Findings 1 actionable finding [P2] Describe the preserved context override precedence
Security None None.

How this fits together

The Codex plugin discovers account models through the Codex app-server. OpenClaw projects that metadata into model listings and context budgeting, alongside explicitly configured model limits.

flowchart TD
 A[Codex account models] --> B[App-server model list]
 B --> C[OpenClaw metadata parser]
 C --> D[Native model catalog]
 D --> E[Context budget resolution]
 F[Configured model limits] --> E
 E --> G[Model display and budgeting]
Loading

Before merge

  • Describe the preserved context override precedence (P2) - When a user has an explicit model context override, this new paragraph incorrectly says native metadata replaces it. The patch only changes discovered catalog values; resolveContextWindowInfo still selects configured limits first, and setup.test.ts explicitly preserves the 1,000,000-token native-Codex override case. State that the metadata supplies catalog defaults and that explicit overrides retain their existing precedence.
  • Resolve merge risk (P1) - The inspected upstream model/list contract does not emit these fields; verify the companion protocol implementation and its runtime meaning before relying on the new catalog limits.
  • Resolve merge risk (P1) - The branch conflicts with current main and modifies a removed provider catalog; resolve the conflicts by adapting the projection and tests to the active native catalog, then verify existing configured limits and older app-server behavior.
  • Complete next step (P2) - Resolve the branch against the active native catalog, verify the upstream context-field contract and existing override behavior, and correct the documentation before merge.

Findings

  • [P2] Describe the preserved context override precedence — docs/plugins/codex-harness-reference.md:429-433
Agent review details

Security

None.

PR surface

Source +39, Tests +16, Docs +5. Total +60 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 40 1 +39
Tests 2 16 0 +16
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 61 1 +60

Review metrics

Metric Value Why it matters
Upstream metadata contract 5 optional response fields added The consumer depends on a companion Codex protocol change that the inspected upstream source does not yet expose.
Production versus test growth production +39 net lines; tests +16 net lines The growth implements parsing and projection, but the projection must be adapted to the current owner before landing.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #93764
Summary: This PR addresses the accurate native-context reporting portion of the closed context-cap report; it does not enable a larger OAuth context window.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Adapt after confirming the upstream contract (recommended)
    Resolve the branch against the active native catalog and verify metadata-present, metadata-absent, and explicitly configured-limit cases against the agreed Codex protocol.
  2. Defer until the protocol is available
    Hold the integration while the companion Codex fields remain unavailable so the consumer is reviewed against an implemented wire contract.

Technical review

Best possible solution:

Publish verified native context metadata through the current harness-owned catalog while preserving explicit user limits and documenting their precedence accurately.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main’s model parser and native catalog omit the proposed context metadata, and this head’s tests establish that configured limits still take precedence. No live failure was executed in this read-only review.

Is this the best way to solve the issue?

No, as submitted: the projection targets the former provider catalog, and its documentation promises precedence the code does not implement. Adapting the same idea to the native catalog is preferable to changing global provider or override policy.

Full review comments:

  • [P2] Describe the preserved context override precedence — docs/plugins/codex-harness-reference.md:429-433
    When a user has an explicit model context override, this new paragraph incorrectly says native metadata replaces it. The patch only changes discovered catalog values; resolveContextWindowInfo still selects configured limits first, and setup.test.ts explicitly preserves the 1,000,000-token native-Codex override case. State that the metadata supplies catalog defaults and that explicit overrides retain their existing precedence.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d1d4342228fc.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded model-context accuracy improvement without evidence of an urgent current-user regression caused by the patch.
  • merge-risk: 🚨 compatibility: New native context values depend on an unfinished upstream contract and need verification alongside existing configured limits and older app-server responses.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: MEMBER authorship exempts ordinary contributor runtime proof, and this metadata change does not trigger authority-chain proof. The body reports tests rather than a live new-field model/list run; upstream-contract verification remains separate required merge work. No stored-data contract changes were identified.

Evidence

What I checked:

  • Pinned introduction: The verified merge-base-to-head delta adds optional context metadata parsing, catalog projection, two test updates, and a documentation claim. The checkout is the original PR head, not a synthetic merge. (extensions/codex/provider-catalog.ts:54, af41016ef592)
  • Dependency signal and validation scope: The PR explicitly consumes Codex app-server model/list fields and identifies an unmerged companion Codex branch. Its captured body reports focused tests and expressly says live model/list with the new fields was not tested. This establishes the Codex dependency gate; MEMBER authorship exempts the ordinary external-contributor proof requirement. (af41016ef592)
  • Personally inspected upstream wire contract: The sibling checkout was inspected directly. Model at codex-rs/app-server-protocol/src/protocol/v2/model.rs:82 has no context-window fields, and model_from_preset in codex-rs/app-server/src/models.rs does not emit them. GitHub verified this source SHA belongs to openai/codex. (codex-rs/app-server-protocol/src/protocol/v2/model.rs:82, a7dff9043085)
  • Native context calculation: Direct inspection found model_context_window multiplying the resolved native window by effective_context_window_percent. ModelInfo resolves context_window before max_context_window; with_config_overrides separately clamps configured windows to the advertised maximum. (codex-rs/core/src/session/turn_context.rs:151, a7dff9043085)
  • Current native catalog owner: Current main calls the harness-owned model catalog, whose projection publishes openai model identities and reasoning capabilities without these context fields. The former provider catalog is absent. This establishes remaining adaptation work, not a verified semantic regression from merging the old head. (extensions/codex/src/app-server/model-catalog.ts:29, d1d4342228fc)
  • Latest release comparison: The latest supplied release revision also uses the native catalog projection without these context fields. Neither the release nor current-main inspection establishes that this PR’s optional wire-metadata behavior is already implemented. (extensions/codex/src/app-server/model-catalog.ts:29, c074824a27c9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Kimi Yu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Adapt the projection and focused tests to the active native catalog while resolving conflicts.
  • Verify the companion model/list contract with metadata present and absent, including explicit configured limits.
  • Correct the documentation’s override-precedence claim.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T08:57:24.847Z sha af41016 :: found issues before merge. :: [P1] Rehome the catalog update on the current owner
  • reviewed 2026-08-15T12:17:06.660Z sha af41016 :: found issues before merge. :: [P1] Rehome the catalog update on the current owner
  • reviewed 2026-08-16T17:56:20.915Z sha af41016 :: found issues before merge. :: [P1] Rehome the context-cap update on the active catalog owner
  • reviewed 2026-08-18T07:31:37.128Z sha af41016 :: found issues before merge. :: [P1] Move the context-cap mapping to the active OpenAI catalog
  • reviewed August 23, 2026, 4:51 AM ET / 08:51 UTC sha unknown :: found issues before merge. :: [P1] Move the context-cap mapping to the active catalog
  • reviewed 2026-08-29T09:07:56.458Z sha af41016 :: blocked before merge. :: [P1] Project context caps through the active catalog
  • reviewed 2026-09-05T16:38:07.218Z sha af41016 :: blocked before merge. :: [P2] Describe the preserved context override precedence
  • reviewed 2026-09-25T09:55:50.898Z sha af41016 :: blocked before merge. :: [P1] Move the cap projection to the active native catalog | [P2] Describe the preserved context override precedence

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 14, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 25, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This PR has been waiting since June on an upstream protocol prerequisite and conflict resolution with no new commits. Please reopen on current main once the app-server context metadata is available.

If this change is still needed, please open a fresh PR against current main and we'll review it there.

@steipete steipete closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants