Skip to content

fix(codex): use session-id header for cache affinity - #156

Merged
raine merged 2 commits into
raine:mainfrom
Getty:fix/codex-session-id-cache-affinity
Sep 17, 2026
Merged

raine merged 2 commits into
raine:mainfrom
Getty:fix/codex-session-id-cache-affinity

Conversation

@Getty

@Getty Getty commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • send the Codex Responses cache-affinity header as session-id instead of session_id
  • keep prompt_cache_key, x-client-request-id, and x-codex-window-id behavior unchanged
  • update the existing header tests and explicitly verify that the underscore variant is no longer emitted

Why

build_codex_headers currently emits session_id. The official OpenAI Codex client emits session-id, and the current Codex source notes that ChatGPT derives Responses cache affinity from that header.

The proxy already supplies a stable prompt_cache_key from the Claude Code session ID. This patch therefore fixes the missing cache-routing signal without changing request-body semantics, continuation state, or session ownership.

Related upstream investigation: openai/codex#44716 reports that session-id can affect reported cache reuse independently of prompt_cache_key on the ChatGPT-authenticated Codex backend. The backend mechanism is still under discussion there, so this PR intentionally stays limited to matching the official Codex wire format.

Scope

This does not add thread-id, prompt_cache_options, or cache breakpoints. It also does not change the existing per-agent continuation ownership logic. Those are separate behavior changes and should be evaluated independently.

Testing

  • cargo fmt --check
  • cargo test codex_headers_

Getty and others added 2 commits September 17, 2026 06:58
Keep the WebSocket continuation integration checks aligned with the current
Codex wire header and verify that the obsolete underscore spelling is absent.

Describe the header as protocol conformance rather than asserting an
unverified backend cache implementation detail.
@raine
raine merged commit 9d496b9 into raine:main Sep 17, 2026
@raine

raine commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Thanks for catching this and for the careful upstream investigation. I updated the continuation integration coverage for session-id and removed the stronger cache implementation claim. The current Codex source and header history confirm the hyphenated form is the right wire format.

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants