Repository navigation
Keep a conversation on the upstream that answered it, and hold a turn's route - #237
Merged
Merged
Conversation
…'s route A conversation (client session header plus the content fingerprint, or the fingerprint alone) now stays on the upstream that last answered it: always within a turn (the last user message is a tool result), and across turns only while the previous answer read or wrote at least 1024 tokens of prompt cache less than five minutes ago. A pinned upstream that is cooling down is released, and a failover member that answered becomes the pin. Pins are scoped by route and group, kept in memory (4096 conversations, 24 hours). The routing decision made at the start of a turn is reused for the rest of the turn, so rules keyed on input size or images no longer move a turn halfway; it is re-evaluated only when the input no longer fits the smallest known context window among its candidates (from the price book). This replaces the load-balance fingerprint-modulo pinning: load-balance now rotates new conversations. `groups[].session_affinity` and `hurts_cache` are removed. RequestRouted and RoutingView gain `affinity` (held_route, stayed: turn | cache). Control API version 29. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
fylorn
added a commit
that referenced
this pull request
Sep 29, 2026
- Bump the workspace version to 0.56.0 - release-notes/0.56.0.md Includes #237 (conversation affinity, route held per turn), #238 (local token counts, resend without sealed reasoning) and #239 (fail over at the start of a stream, pause upstreams by the reason they give). The control-plane protocol goes from 28 to 30; the request store schema (22) is unchanged. groups[].session_affinity is removed. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Routing rules were re-evaluated on every request, and only
load-balancegroups pinned a session (by fingerprint modulo). A rule keyed oninput_tokensorimagecould flip halfway through an agent turn, and any failover or reordering moved a conversation away from the upstream holding its prompt cache.tw_gateway::affinity::identity): a client session header (x-claude-code-session-id,session_id,session-id,conversation_id,x-session-affinity,x-opencode-session) hashed together with the existing content fingerprint (session::fingerprint, which already honoursprompt_cache_key), or the fingerprint alone. The fingerprint is kept alongside the header so side requests and sub-agents under one Claude Code session stay separate conversations.withinwhen the last user message carries a tool result.max_input_tokensamong the candidates' asked models (price book); unknown windows skip the check.Ending), including a failover member. Scoped by route + group. Stay rules: within a turn always; across turns only if the previous answer'scache_read + cache_write >= 1024and it was < 5 min ago. Released when the upstream is notHealth::is_available, not among the candidates, or in another group. In memory, 4096 conversations, 24 h.Facts::session,groups[].session_affinityandhurts_cacheare removed (no strategy drops a warm cache mid-conversation any more).RequestRouted/RoutingViewgainaffinity: { held_route, stayed?: "turn" | "cache" }(optional; no DB schema change).Control API (28 → 29)
GroupView.session_affinity,GroupView.hurts_cache,GroupInput.session_affinity,DryRunResult.hurts_cache.AffinityView,Stay,RequestRouted.affinity,RoutingView.affinity.groups[].session_affinityis gone;Groupisdeny_unknown_fields, so a config that still has it fails to load.Not covered
provider_would_be) are still evaluated per hop.Tests
affinity.rs): header vs hash identity, turn detection, route held within a turn / not across turns / not across config reloads, within-turn stay regardless of cache, cross-turn stay vs release by cache size and age, release when cooling down, failover member becomes the pin, group scoping, bounds/expiry.tests/affinity.rs): a turn keeps its rule and upstream while its input grows past aninput_tokensrule, the next turn stays on the warm upstream, and a new large turn re-decides.🤖 Generated with Claude Code