translate: send x-grok-conv-id affinity header for grok via openai_gateway - #1121
Conversation
|
PR author is not in the allowed authors list. |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Claude finished @devin-ai-integration[bot]'s task —— View job No comment-length issues found — no added comment blocks of 3 or more consecutive lines. |
Runtime wire verification: x-grok-conv-id via openai_gatewayRan this branch locally in docker compose against mock gateway upstreams and inspected the mocks' request logs. ✅ grok-4.6 via ✅ Non-grok gateway model ( ✅ Strip-and-retry survival (strict gateway that 400s
(Direct first-party OpenAI absence not runtime-tested; the header is gated on |
Summary
xAI's prompt-caching docs say the cache-routing knob on Chat Completions is the
x-grok-conv-idHTTP header;prompt_cache_keyis only honored on their Responses API. #1101 sends the body-levelprompt_cache_keyforopenai_gatewaytargets, which xAI ignores on chat/completions — so grok served through a BYOK gateway (e.g. Snowflake Cortex) still misses the warm cache.applySessionAffinitynow also sets the header when the gateway target is a grok model:StripPromptCacheKey— a gateway 400ing on the body field says nothing about headers.x-grok-conv-idreturnedcached_tokens=2304(of 2348), whileprompt_cache_keyalone (body, either surface) returned 0 across all probes. Cache hits remain best-effort — repeats can still land cold replicas.Tests:
session_affinity_test.go— gateway grok gets the header, non-grok gateway and direct-OpenAI grok don't, header kept on the strip-and-retry path.Link to Devin session: https://app.devin.ai/sessions/85739dd5156f4ffd9b4ce1941cd91e13
Open in Devin Desktop: https://app.devin.ai/desktop/session/85739dd5156f4ffd9b4ce1941cd91e13?variant=devin
Requested by: @steventohme