Repository navigation
fix(provider): route each session to its OpenAI and xAI prompt cache - #461
Conversation
|
@codex review |
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: Didn't find any major issues. Already looking forward to the next diff. 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". |
ee6612c to
b66670c
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
Stacked on #460.
OpenAI and xAI cache prompt prefixes implicitly, but a hit needs the request to reach the machine that holds the prefix. QQ sent no routing signal. Over the last 21 days of local sessions,
openai-codex/gpt-6.1-solread only 39.5% of its input from cache (356M uncached input tokens; Claude routes read 95%). 1,475 of its turns sent more than 50k input tokens with zero cache read, all after a run's first turn. Codex and Pi both send the session id for this; OpenCode sends xAI's conversation header.What changed
ModelRequest::with_cache_key: a session run (every turn, follow-up runs, and the in-run summarizer, which shares the run's prefix) sends its session id as the key. Direct runs send none.CacheRoutingon the HTTP recipe decides how the key reaches the wire, and only for built-in endpoints, which configuration cannot redirect:openai,openai-codex: Responsesprompt_cache_key. The Codex body also sends thesession-idheader that the ChatGPT backend derives cache affinity from (as Codex and Pi do).xai:x-grok-conv-id.Verification
every_session_request_carries_the_session_as_its_cache_key(two runs in one session) and the in-run summarizer assertion inan_in_run_summarizer_keeps_the_session_context_before_its_promptboth failed with the session-layer lines removed and pass with them.session-id; xAIx-grok-conv-id.cache_routing_follows_the_builtin_routepins the route table.prompt_cache_keyappears 0 times in the captured request, as intended for custom endpoints.cargo xtask checkpasses. Sixxtask/src/legacy-sleeps.txtline numbers moved; each was checked to still name the same sleep.Not verified
There are no live provider calls in tests, so the cache-hit improvement itself is unmeasured. Measure it with the same
model_turns.usage_jsonquery on newopenai-codexturns after this merges.