Skip to content

fix(claude): cache the GPT-6.2 system prompt on Codex login - #9019

Merged
lidge-jun merged 4 commits into
lidge-jun:devfrom
JakobM7:codex/claude-gpt62-cache-pr
Nov 21, 2026
Merged

lidge-jun merged 4 commits into
lidge-jun:devfrom
JakobM7:codex/claude-gpt62-cache-pr

Conversation

@JakobM7

@JakobM7 JakobM7 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • For Claude Messages requests translated to GPT-6.2 Sol or Astra on the Codex Login endpoint, send the top-level system prompt as the first developer message in the Responses input. This lets the system prompt be reused as part of the cached prefix.
  • Gate the change on the final upstream model and endpoint. Keep the conversation and its existing developer messages in order.
  • OpenAI documents that top-level instructions are billed as uncached input on GPT-6.2 and recommends a leading developer message for reusable instructions. See Keep the prefix unchanged.

Verification

Live cache check

Paired replays of three requests produced by Claude Code 2.1.329 in one tool-free session, using GPT-6.2 Sol via Codex Login. Each pair shared the same system text and conversation, with a separate cache key per variant. The top-level system prompt stayed stable across all three turns. Counts are cached input tokens / total input tokens, as reported by the Responses API.

Turn Before, top-level instructions After, leading developer message
1 0 / 4158 0 / 4158
2 2432 / 4174 3968 / 4174
3 2432 / 4192 3968 / 4192

Local checks

  • bun run typecheck passed with Bun 1.4.4.
  • bun test --test-name-pattern 'carries cache affinity and system placement' tests/claude-integration/claude-messages-endpoint.test.ts passed all 3 cases for GPT-6.2 Sol, Astra, and the GPT-6.1 control.
  • bun test --isolate --parallel=2 tests/claude-integration/claude-inbound-cache-stabilize.test.ts tests/claude-integration/claude-tool-loading-destinations.test.ts tests/claude-integration/claude-native-fast-1m-ingress.test.ts passed all 66 tests.
  • bun run privacy:scan and git diff --check upstream/dev...HEAD passed.
  • A prior bun run test:changed run on the original fork base reached the 900-second timeout (exit 124) after reporting 73 failed tests. Local validation on this branch covers the focused checks above.

Maintainer follow-up (review round)

  • Moved the placement paragraph from structure/data-planes/inbound-compat.md (it had reached 606 of 600 lines and failed structure:check) to structure/providers/codex-installation-identity.md, an owner of src/adapters/openai-responses/passthrough.ts.
  • Updated the Claude Code guide tables in es, fr, ja, ko, ru, tr, zh-cn and zh-tw to match English.
  • Added a GPT-6.2 case without a system prompt (no instructions, nothing prepended); the placement test now has 4 cases and fails 2 of them on origin/dev's adapter.
  • Merged current dev. On the merged head: bun run typecheck, bun run structure:check and bun scripts/file-size-ratchet.ts exit 0; claude-messages-endpoint + claude-inbound-cache-stabilize with --isolate 106 pass; docs parity tests 445 pass. Independent review: APPROVE-WITH-NITS, nit fixed.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features
    • For GPT-6.2 Sol and Astra requests through Codex login, top-level system instructions are sent as the first developer message. System messages within the conversation are converted to developer messages in their original positions.
  • Documentation
    • Updated the Claude Code guides and adapter documentation to describe system-instruction handling across supported routes.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For qualifying Anthropic-inbound requests to GPT-6.2 Sol or Astra, the Responses adapter moves non-empty instructions into a leading developer input. Integration tests and documentation cover this mapping.

Changes: System prompt placement

Layer / File(s) Summary
Conditional adapter transformation and validation
src/adapters/openai-responses/passthrough.ts, tests/claude-integration/claude-messages-endpoint.test.ts
For qualifying requests, the adapter removes top-level instructions and prepends their content as a developer input. Parameterized tests check placement for GPT-6.2 Sol and Astra, the late-system case, and the case with no top-level system prompt.
Documented system prompt mapping
structure/providers/codex-installation-identity.md, docs-site/src/content/docs/guides/claude-code.md, docs-site/src/content/docs/*/guides/claude-code.md
The documentation describes the GPT-6.2 Sol and Astra Codex-login exception for top-level system text. It also describes messages[].role: "system" as a developer message at its original position.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: Minimal · up to 77c08

For GPT-6.2 Sol and Astra via Codex login, the top-level system prompt is now sent as the first developer message so it can be cached. Other routes are unchanged, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(claude): cache the GPT-6.2 system prompt on Codex login" matches the main change. The PR places a top-level system prompt as the first developer message for GPT-6.2 Sol and Astra over C…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(claude): cache the GPT-6.2 system prompt on Codex login" matches the main change. The PR places a top-level system prompt as the first developer message for GPT-6.2 Sol and Astra over Codex login so the prompt can be cached. The raw summary also covers the matching docs updates and the parameterized integration test. The title is specific, concise, and free of file lists or vague terms.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a105d27 and 77c0873.

Files ignored due to path filters: 1

  • tests/codex-integration/__snapshots__/catalog-omit-disabled-native.test.ts.snap is excluded by !**/*.snap
Files selected for processing: 12

  • docs-site/src/content/docs/es/guides/claude-code.md
  • docs-site/src/content/docs/fr/guides/claude-code.md
  • docs-site/src/content/docs/guides/claude-code.md
  • docs-site/src/content/docs/ja/guides/claude-code.md
  • docs-site/src/content/docs/ko/guides/claude-code.md
  • docs-site/src/content/docs/ru/guides/claude-code.md
  • docs-site/src/content/docs/tr/guides/claude-code.md
  • docs-site/src/content/docs/zh-cn/guides/claude-code.md
  • docs-site/src/content/docs/zh-tw/guides/claude-code.md
  • src/adapters/openai-responses/passthrough.ts
  • structure/providers/codex-installation-identity.md
  • tests/claude-integration/claude-messages-endpoint.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

…locale

Review follow-up for lidge-jun#9019. The placement paragraph moves from
structure/data-planes/inbound-compat.md (which it pushed to 606 of 600 lines) to
structure/providers/codex-installation-identity.md, an owner of
src/adapters/openai-responses/passthrough.ts. The es, fr, ja, ko, ru, tr, zh-cn and
zh-tw Claude Code guides get the same table rows as English: the GPT-6.2 Sol/Astra
system-prompt placement and messages[].role "system" translated to developer messages
in place. The endpoint test adds a GPT-6.2 request without a system prompt, which must
send no instructions and prepend nothing.
@lidge-jun
lidge-jun marked this pull request as ready for review November 21, 2026 06:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T06:48:25.498350Z 77c0873 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md maintainer-integration exception; lane fb2101-queue-b).

  • Exact head: 77c0873157462afaa4adf0b9081d549ec625d8bd
  • Checks on this head: all completed checks pass (ci with gates and test changed, CodeRabbit, enforce-target, hygiene); none pending or failing.
  • Review: terra review, two rounds. Round 1 found the placement paragraph pushed structure/data-planes/inbound-compat.md to 606 of 600 lines (structure:check failed) and that eight translated Claude Code guides still described the old mapping. The maintainer moved the paragraph to structure/providers/codex-installation-identity.md (an owner of passthrough.ts), updated the es, fr, ja, ko, ru, tr, zh-cn and zh-tw tables, added a GPT-6.2 case without a system prompt, fixed a final-newline nit, and merged dev. Round 2: APPROVE-WITH-NITS, nit fixed. The placement test fails 2 of 4 cases on origin/dev's adapter and passes here; the GPT-6.1 control confirms the existing message-level system -> developer mapping.
  • Merged with current dev locally before merging: typecheck, structure:check, file-size ratchet, docs parity, test-layout, core-lab boundary and the focused suite pass.
  • Review threads: 0 unresolved.
  • Scope: bug fix for reduced prompt-cache reuse on GPT-6.2 Sol/Astra via Codex login (src/adapters/openai-responses/passthrough.ts) plus docs; no auth, workflow, release, dependency or provider-preset surface.

This is maintainer integration, not an independent approval.

@lidge-jun
lidge-jun merged commit 8305d50 into lidge-jun:dev Nov 21, 2026
41 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants