[DO-NOT-MERGE-YET] complexity cache-aware session routing integration - #6043
Closed
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This was referenced Aug 11, 2026
Closed
Closed
Contributor
Author
This was referenced Aug 11, 2026
18 tasks
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 11, 2026 12:48
82164fb to
3fbdd04
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 11, 2026 12:48
3b88289 to
23a3626
Compare
18 tasks
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 11, 2026 19:10
3fbdd04 to
ef83df2
Compare
kohlivrinda
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 12, 2026 11:31
ef83df2 to
7a3d7cc
Compare
kohlivrinda
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 12, 2026 11:31
62bf1ca to
10baa8b
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 12, 2026 15:14
10baa8b to
78992e7
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 12, 2026 15:14
7a3d7cc to
06cc703
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 12, 2026 19:25
78992e7 to
f2dafca
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 12, 2026 19:25
06cc703 to
06f15e6
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 12, 2026 22:06
f2dafca to
b98813a
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 12, 2026 22:06
06f15e6 to
b52c3cc
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_routing_integration
branch
from
August 12, 2026 22:20
b52c3cc to
97a29d7
Compare
Madhuvod
force-pushed
the
08-11-_do-not-merge-yet_complexity_cache-aware_session_tier_policy
branch
from
August 12, 2026 22:20
b98813a to
5f49487
Compare
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
Cache-aware session mode previously shared a single code path with pinned mode, which meant it could not correctly handle per-turn classification, atomic tier-change decisions, or the distinction between a held tier and a freshly classified one. This PR splits the two modes into separate implementations so each behaves correctly and independently.
Changes
classifyWithPinnedSessionandclassifyWithCacheAwareSessionfrom the singlewithComplexitySessionclosure, replacing a mode-conditional branch inside one function with two dedicated paths dispatched by aswitchonstate.Config.Mode.store.Updateatomically to decide whether the session may move. An unchanged decision aborts the replicated write and falls back to a coarseGetto slide the TTL, avoiding one write per request when the tier is stable.ModeandTTLfields oncomplexitySessionStatewith a singleConfig configstore.ComplexitySessionConfigsnapshot, so both paths read from the same policy values captured at request start and cannot mix thresholds from a concurrent config reload.publishCacheAwareSessionTierto log the policy decision (tier, proposed tier, switched flag, reason, identity) and clear the score from context when the held tier differs from the proposal, preventing a score calculated for one tier from being attributed to another.persistInitialSessionTieras a shared helper used by both modes when writing the first record for a new session.errSessionTierDecisionUnchangedsentinel soUpdatecan abort without a replicated write while still allowing the caller to distinguish a no-op from a real error.failingUpdateSessionStoretest double and five new test cases covering: no replicated write on an unchanged cache-aware tier, escalation with semantic mechanism preserved, sustained-downgrade gating, hold when classification produces no tier, and fallback to the proposal whenUpdatefails.Type of change
Affected areas
How to test
Validate cache-aware behaviour end-to-end by configuring a session with
mode: cache_aware, sending several turns with the same session identity, and confirming via routing engine logs that:Cache-aware complexity sessionlog entry withswitched=falsewhen the tier is stable.switched=trueand the new tier takes effect immediately.pending_turnsuntildowngrade_after_n_turnsis satisfied before switching.Breaking changes
Related issues
Security considerations
No auth, secrets, PII, or sandboxing changes. Session keys remain tenant-namespaced and TTL-bounded as before.
Checklist
docs/contributing/README.mdand followed the guidelines