Skip to content

fix(core): send Codex session headers with ChatGPT token sharing - #53767

Merged
rekram1-node merged 1 commit into
v2from
chatgpt-cache-ids
Oct 7, 2026
Merged

rekram1-node merged 1 commit into
v2from
chatgpt-cache-ids

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Sign in with ChatGPT (token sharing) requests go to api.openai.com/v1 with only the shared prompt_cache_key. The legacy Codex route also sends a session-id header, which ChatGPT uses for prompt-cache affinity, and Codex itself sends session-id, thread-id, and x-client-request-id. Testing showed token-sharing cache reuse near zero while the Codex route caches normally (#53765).

This adds a model.request hook to the token-sharing plugin that sends:

  • session-id: the session's cache-affinity ID (the parent for child sessions, matching the Codex route)
  • thread-id and x-client-request-id: the current session ID

API-key OpenAI connections and the Codex route are unchanged.

This is an experiment: whether the token-sharing backend actually routes its cache on these headers still needs a live check.

Tests

  • bun test test/plugin/provider-chatgpt.test.ts test/plugin/provider-openai.test.ts
  • bun run typecheck in packages/core

Refs #53765

Requested by: @rekram1-node (Aiden Cline via Slack)

ChatGPT token sharing only sent prompt_cache_key, while the legacy Codex route also sends a session-id header that ChatGPT uses for prompt-cache affinity. Send session-id, thread-id, and x-client-request-id on token-sharing requests the way the Codex client does.
@rekram1-node
rekram1-node merged commit 5183ea4 into v2 Oct 7, 2026
11 checks passed
@rekram1-node
rekram1-node deleted the chatgpt-cache-ids branch October 7, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant