fix: prompt-cache max for xAI and Codex (git-root + HUD) - #661
Closed
justrach wants to merge 3 commits into
Closed
Conversation
xAI partitions cache by prompt_cache_key. Hashing the leaf cwd made every graff-evals sandbox a cold ~8k write (rematch first-call cache 0–512 vs grok 11k–43k already warm). Seed is the git root so worktrees and sibling sandboxes share; scratch -p uses graff-scratch. Prefix bytes still have to match. ADR 0011.
xAI and Codex already share cache_affinity.rootId (git-root / graff-scratch) for prompt_cache_key. /cache only named the xAI headers, so a Codex session looked like it had no affinity. Record the wire, print session_id = prompt_cache_key, and pin ADR 0028: same id as xAI, no Platform breakpoint (the ChatGPT backend 400s it).
justrach
marked this pull request as ready for review
August 28, 2026 07:49
Native Anthropic only marked system + last message; the last-tool breakpoint was gated on is_kimi, so a long tool loop could walk the 20-block lookback off the system write. /cache now names Claude and Kimi instead of showing a unused key as Claude affinity.
Owner
Author
|
Already on main (prompt-cache max HUD + Claude last-tool cache_control). Closing as superseded. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prompt-cache max for both wires, not just xAI. Verified OOTB against Codex (DeepWiki /
ModelClient), Claude’s currentcache_controldocs, and Kimi’s context-cache + chat OpenAPI.What was already true
Codex HTTP/WS
session_idalready equals the Responsesprompt_cache_key(ADR 0028). Both wires callprojectRootId. We do not sendprompt_cache_options/prompt_cache_breakpointon Codex — the ChatGPT backend 400s them (openai/codex#35300).What was wrong
/cacheonly named xAI headers. A Codex session looked like it had no affinity.writeAnthropicTools(..., is_kimi)). A long tool loop can walk Anthropic’s 20-block lookback off the system write.This PR
graff-scratchwith no repo). Worktrees and eval sandboxes share. Includes fix: key prompt-cache affinity on git root, not cwd #659./cacheprints Codex assession_id = prompt_cache_keyon the same id. OpenAI Platform still gets the ADR 0009 breakpoint. Claude and Kimi are named on their own contracts (no fake Claude key).cache_control(that would be a 4th slot / no-op).prompt_cache_key(Code Plan / coding-agent). Unchanged.You can just use it: pick the provider,
/cachenames the live contract. Merge this one if you want both wires in one shot (stacks on #659).