translate: send session-affinity hints to openai_gateway and anthropic_gateway endpoints - #1101
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 ✓ |
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion on |
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nit. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
No comment blocks of 3+ lines warranting a flag. The |
Runtime Cortex-style gateway verificationVerified the router locally against a strict bearer-authenticated Cortex-style mock gateway (rejects unknown top-level body fields with 400). ✅ ✅ Caller Anthropic metadata: ✅ Claude Code: ✅
✅ Regression, direct first-party ✅ Strict-gateway compatibility: every gateway-bound body passed the strict field allowlist (all 200s). |
Resolve internal/proxy/service.go: keep main's surface-based dispatchOpenAI refactor and re-apply the prompt_cache_key strip-and-retry (per-attempt StripPromptCacheKey, pre-commit retry, endpoint memoization) on top.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion on |
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nit. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion review with 3 nits on comment-length:
|
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion review with 3 nits on comment-length:
|
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion review with 2 nits on comment-length:
|
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
No comment blocks of 3+ lines warranting a flag. All added blocks that reached 3+ lines were already reviewed and trimmed in this PR's previous commits ( |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a79ab21. Configure here.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion review with 2 nits on comment-length:
|
Runtime verification vs Cortex-shaped mock gateways (both surfaces)Ran the branch build locally against two mock gateways: a Cortex-faithful one (accepts
One gap found: the Responses emit path ( |
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
Posted one advisory suggestion review with 2 nits on comment-length:
|
workweave-bot
left a comment
There was a problem hiding this comment.
Advisory only — comment-length nits. Won't block merge.
|
Claude finished @devin-ai-integration[bot]'s task —— View job
No comment blocks of 3+ lines warranting a flag. All added blocks that reached 3+ lines were already reviewed and trimmed in this PR's previous commits. Remaining blocks explain genuinely non-obvious behavior concisely: each 3-line block carries distinct WHY content that cannot be cut further without losing the invariant. |

Summary
applySessionAffinitydeliberately sent no cache-affinity hint to gateway providers ("no affinity contract; may reject unknown headers"). In a customer's 2026-08-27 benchmark run this meant grok-4.6 served via their BYOKopenai_gatewayfanned across replicas with ~11% cache-read rate: 53.3M full-price input tokens vs 6.5M cache reads, inflating cost and pushing uncached 30k-token prefills toward the 30sResponseHeaderTimeout(189 status-0 failures; see WorkWeavedocs/eval/RESULTS_snowflake_clone_sqlbench_roster163a_20260827.mdFollow-up 10).Fix avoids the unknown-header/unknown-field concern by riding spec fields the gateway forwards with the body:
openai_gatewayjoins the existingProviderOpenAIcase:prompt_cache_key= session key, else stable prefix hash, else unhinted; caller-supplied key preserved.anthropic_gatewaygets a newapplyAnthropicSessionAffinityon thePrepareAnthropicpath:metadata.user_id= session key, only when the caller didn't send one (Claude Code's own bundle is already a usable affinity key). First-party Anthropic is untouched. Cortex rejects non-spec top-level keys, so a spec Messages field is the safe carrier.Coverage map pins
ProviderOpenAIGateway: mechanismPromptCacheKeyBody, plus dedicated unit tests for both gateways (set / preserve-caller / direct-provider-unhinted / empty-no-op).wv router tcandwv router tpass.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