🤖 fix: preserve Codex OAuth prompt cache routing - #4159
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebbd0506af
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4bf03bf4b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Implementation and review are complete at
No merge/deployment performed. Diagnostic credentials were already removed; this implementation reused the bounded recorded live evidence for unchanged ASCII scopes and added offline encoding/normalization regressions. Generated with |
Forward the existing stable prompt cache scope as session-id on Codex OAuth Responses requests, preserving explicit headers and keyless callers. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-6-astra` • Thinking: `off` • Cost: `$36.74`_ <!-- mux-attribution: model=openai:gpt-6-astra thinking=off costs=36.74 -->
Project scopes include names that may contain Unicode or control characters. Encode the stable scope rather than letting Headers reject it and skip normalization. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-6-astra` • Thinking: `off` • Cost: `$48.99`_ <!-- mux-attribution: model=openai:gpt-6-astra thinking=off costs=48.99 -->
Replace lone UTF-16 surrogates via UTF-8 before encoding the stable session scope. Assert that normalization still strips truncation and disables storage. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-6-astra` • Thinking: `off` • Cost: `$61.26`_ <!-- mux-attribution: model=openai:gpt-6-astra thinking=off costs=61.26 -->
d077fb5 to
2fb3246
Compare
|
Rebased onto Fresh validation: 353 tests / 837 assertions passed, plus The current-main comments gate still reproduces the false failure: 0 unresolved threads, but 3 clean security verdict comments classified as unresolved. Main strips the Requesting fresh reviews for the rewritten head; merge queue remains gated on green checks and clean final review. Generated with |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Accept the plain and auto-triggered security-review headings without exempting findings, appended findings, or repeated/unknown envelopes. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-6-astra` • Thinking: `high` • Cost: `$108.19`_ <!-- mux-attribution: model=openai:gpt-6-astra thinking=high costs=108.19 -->
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Forward a header-safe encoding of Xum's existing stable
prompt_cache_keyas a missingsession-idfor Codex OAuth Responses requests. The tested Codex backend uses this header for cache routing; keeping only the body key caused repeated misses.Headers.set()reject the request. No new IDs, persistence, or thread/turn-state headers.Evidence
A controlled diagnostic on
289277eb7sent 14 byte-identical 6,177-token Astra OAuth bodies. In-phase completion-to-next-request gaps were ~14s (phase boundaries ~30–35s):mux-v1-…scope as sessionThe returned cache key followed
session-ideven when it differed from the body key. This is a reversible header-only result, not an inference from absent headers or changing response keys alone.The initial header-forwarding patch was then dogfooded using dev-server-sandbox + agent-browser, a no-tools synthetic project, and existing unexpired OAuth credentials. Normalized instructions/tools/cache key stayed identical; every turn preserved the input prefix and appended two items. Baseline chat turns had 0 cache reads. The patched path went cold → 1,664/1,857 cached tokens (89.6%), visible in Stats.
Sanitized sandbox screenshots and recording
Before:

After:

browser-fix.webm
Validation
50b357e67: 353 targeted tests passed (providerModelFactory.test.ts,providerOptions.test.ts), ~1s.make static-checkpassed: both TypeScript projects, ESLint, formatting, generated-source/docs checks.Codex CI parser fix
The user authorized including the narrow CI fix here to unblock the merge. Accept both observed security-review headings (plain and automatically triggered), strip only one heading, and leave the existing exact clean-verdict matching intact. Findings, appended findings, repeated headings, unknown metadata, and incomplete summaries remain blocking; informational metadata still does not count as approval.
./scripts/check_codex_comments.sh 4159passes with zero blocking comments.make static-checkpassed again on the completed change.Recorded terminal verification
Accelerated terminal replay (idle delays removed):
parser-verification-fast.webm
Limits / review focus
This evidence covers one account and Astra over Codex HTTP, not every model/account or a public OpenAI API contract. It does not prove a regression introduced by a particular update; released v0.28.4 has the same omission. Cold-start misses, prefix churn, eviction, and callers without a stable cache scope remain possible. Project-wide scope reuse retains Xum's existing policy; explicit session IDs remain authoritative.
Official Codex
rust-v0.153.4also sends session/thread/client-request headers on HTTP (source); the controlled isolation above shows that thread/client-request headers are unnecessary for this fix. Server-issuedx-codex-turn-stateis deliberately not replayed across turns.Merge queue only after all required CI and final review gates pass; no deployment changes.
Generated with
mux• Model:openai:gpt-6-astra• Thinking:off• Cost:$108.19