Repository navigation
Description
Client or integration
Other
Area
Proxy and routing
Summary
Grok Build (the grok CLI, wired by ocx through the managed [model_providers.opencodex] block with x-opencodex-grok = "1") gets almost no prompt-cache reuse when it uses an OpenAI model served by the ChatGPT Codex backend (for example gpt-6-astra). The same model used from Codex reuses the prefix normally.
From the last 400 request-log entries on one machine:
| Surface | Model | Requests | Cached input share | Affinity |
|---|---|---|---|---|
| Codex | gpt-6-astra | 122 | 97.1% | — |
| Grok | gpt-6-astra | 88 | 13.6% | new_bind on all 88 |
| Grok | claude-opus-5-5 | 31 | 90.8% | — |
The Grok rows show cachedInputTokens of 0 or a fixed 3200/4992 regardless of conversation length, and conversationId is never set.
Cause: Grok sends its conversation identity as x-grok-conv-id / x-grok-session-id and as the body prompt_cache_key, but it never sends the session_id header that Codex clients send. The ChatGPT Codex backend only reuses a warmed prefix when session_id is present, and opencodex also reads that header for thread affinity and request-log conversation identity. Grok's request bodies are append-only across turns (checked by diffing consecutive captured bodies: tools identical, input a strict prefix), so the client is not the problem.
Reproduction
ocxwith an OpenAI (ChatGPT) account and the Grok integration enabled.- In Grok Build, pick
ocx-gpt-6-astraand run a multi-turn task (several tool calls). - Open Logs: every Grok/gpt-6-astra row is
affinity: new_bindand cached input stays near zero.
A/B confirmation by replaying one captured Grok request body (≈16.7k input tokens) three times against /v1/responses with the Grok headers:
| Replay | cached_tokens |
|---|---|
no session_id header |
0 → 0 → 0 |
session_id = the body's prompt_cache_key |
0 → 16640 → 16640 |
Version
2.76.0 (dev at 4b74668)
Operating system
macOS (aarch64)
Provider and model
openai (ChatGPT Codex backend, pool account) / gpt-6-astra, Grok Build 1.0.46
Logs or error output
surface=grok model=gpt-6-astra affinity=new_bind conversationId=<none> usage.inputTokens=42565 cachedInputTokens=3200
Screenshots and supporting files
Logs page with consecutive Grok gpt-6-astra rows at 2만+ tokens and cache c 3200 or none.
Redacted configuration
[model_providers.opencodex]
base_url = "http://127.0.0.1:10100/v1"
api_backend = "responses"
api_key = "opencodex-loopback"
[model_providers.opencodex.extra_headers]
x-opencodex-grok = "1"Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
fix(grok): forward the Grok conversation as session_id so OpenAI pref…
lidge-jun commentedon Oct 3, 2026
Fixed on dev by #6482.