fix: resolve routing tier for fallback and affinity-reuse decisions - #273
fix: resolve routing tier for fallback and affinity-reuse decisions#273thossullivan wants to merge 1 commit into
Conversation
Walkthrough
ChangesTier Routing and Observability
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/libsy/tests/observability.rs`:
- Around line 1233-1245: Extend the observability test around the two-request
loop to track non-routed judge calls in ClassifierClient, then assert that the
second request does not increase that count. Keep the existing routing_tier
assertions, and use the recorded call count to verify the second request reuses
the session-affinity decision path rather than invoking the judge again.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d2d5e19e-2405-44c7-8282-6f94390ca9cb
📒 Files selected for processing (2)
crates/libsy/src/algorithms/fall_through.rscrates/libsy/tests/observability.rs
|
@thossullivan Thanks for putting up the PR. Can you put up a Issue and link a PR to that. |
|
Filed #276 for this and linked it in the description. Thanks for the look! |
|
@thossullivan Thanks for putting up the PR. Can you please rebase over main once |
74603e1 to
88983fc
Compare
|
@ayushag-nv sorry for the delay, bad storms knocked out our power for about a week! Rebased. It became a rewrite rather than a replay. The original commits patched The gap survives in the decision log, where #338 moved the detail and #413 turned it into a log message. The branch is now one commit that resolves the tier across the cascade when the deciding classifier defines none, plus two tests covering the fallback and affinity-reuse paths that fail without it. If you would rather the tier stay out of this path entirely, I am still happy to close or work on the cleanup instead! |
Only the deciding classifier is asked for the routing tier, so a selection made by the cascade fallback (DefaultTarget) or served from an affinity pin (AffinityRouter) logs tier: None, while a judged selection of the same target logs its tier. Neither decider implements Classifier::routing_tier, so the trait default applies. Resolve the tier across the cascade when the deciding classifier defines none, so a selection names its tier regardless of which classifier decided. Tests: fallback_decision_logs_the_routing_tier in crates/libsy-llm-client/tests/observability.rs, which fails without the fall_through.rs change. Signed-off-by: thossullivan <tomhsullivan@outlook.com>
88983fc to
0d6313f
Compare
|
@nachiketb-nvidia No problem at all with the rebases! Love the progress on the repo :) Rebased onto main and reduced to the single test as requested. The refactor actually made this even simpler. With the tier now a structured field on the |
Closes #276.
Why
A routing decision made by the cascade fallback, or served from an affinity pin, logs without its routing tier while a judged decision to the same target logs with one:
#338 preserves routing-tier and fallback details in the decision reasoning and #413 moved that reasoning into the log, so a decision that omits the tier loses detail the log is meant to carry.
What
with_routing_tierasks only the deciding classifier for the tier. NeitherDefaultTargetnorAffinityRouterimplementsClassifier::routing_tier, so the trait default returnsNoneand the tier is dropped. This resolves the tier across the cascade when the deciding classifier defines none.How
One lookup in
crates/libsy/src/algorithms/fall_through.rs: fall back to the first classifier in the cascade that defines a tier for the selected target.TaskClassifiersits in the cascade in both cases, so the fallback and affinity paths resolve the sameweak/stronglabels a judged decision would produce.Test Plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test -p switchyard-protocol -p switchyard-libsy -p switchyard-llm-client -p switchyard-servergit diff --checkuv run ruff check .uv run mypy switchyarduv run pytest tests/ -m "not integration"Two tests in
crates/libsy-llm-client/tests/observability.rscover the fallback and affinity-reuse paths. Both fail without thefall_through.rschange.Note on this branch
This was rebased at maintainer request and became a rewrite rather than a replay. The original commits patched
FallThroughDecision.tierand asserted atierattribute onswitchyard.requests; #338 removed both, so there was nothing left for them to apply to. The defect they described survives in the decision log, and this branch addresses it there.