Repository navigation
feat(libsy): warn when affinity cannot derive a key - #308
Conversation
WalkthroughChangesSession handling
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/libsy/src/algorithms/util/affinity.rs (1)
121-167: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winWarn when a child request has no usable affinity identity.
If
metadata.is_subagentis true andagent_idis absent, lines 121-125 returnNone. If its session ID is absent or empty, lines 138-141 also returnNone. Neither path reaches the one-time warning at line 154.Return early only for intentional
subagents_onlyroot abstention. Preserve child message-hash fallback abstention, but let child requests without a usable{session_id, agent_id}pair consume the warning. Add regressions for both paths.As per PR objectives, affinity must warn once when it cannot derive a key.
Also applies to: 515-577
🤖 Prompt for 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. In `@crates/libsy/src/algorithms/util/affinity.rs` around lines 121 - 167, Update the affinity key derivation flow so child requests lacking a usable agent_id or session identity reach the one-time unkeyed warning via should_warn_unkeyed. Keep the intentional subagents_only root-request abstention and child message-hash fallback abstention behavior, but ensure both missing-identity paths warn once before returning None. Add regressions covering a subagent without agent_id and a subagent with an absent or empty session ID.
🤖 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.
Outside diff comments:
In `@crates/libsy/src/algorithms/util/affinity.rs`:
- Around line 121-167: Update the affinity key derivation flow so child requests
lacking a usable agent_id or session identity reach the one-time unkeyed warning
via should_warn_unkeyed. Keep the intentional subagents_only root-request
abstention and child message-hash fallback abstention behavior, but ensure both
missing-identity paths warn once before returning None. Add regressions covering
a subagent without agent_id and a subagent with an absent or empty session ID.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e6a1aa02-41be-4822-a300-e3afe2b3eca8
📒 Files selected for processing (3)
crates/libsy/src/algorithms/util/affinity.rscrates/protocol/src/metadata.rscrates/switchyard-server/src/lib.rs
0e2fda8 to
a20a712
Compare
a20a712 to
5f80d1d
Compare
bb4c5b1 to
9918c90
Compare
9918c90 to
c48f442
Compare
c48f442 to
82c1b21
Compare
d2318ac to
a144ddc
Compare
Signed-off-by: Joel Fernandes <[email protected]>
a144ddc to
1dbbc01
Compare
What
subagents_onlyroot abstention silent.Why
session_affinity = truecan be silently inert when a request supplies no supported session metadata andmessage_hash_fallbackis disabled. Every turn is then classified again even though affinity is configured.Benchmark clients without session metadata can enable
message_hash_fallbackas a best-effort task key. Production clients should send a generic supported session header such asx-switchyard-session-id.Addresses the warning portion of #301.
How tested
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test -p switchyard-libsyuv run ruff check .uv run pytest tests/Scope
This PR does not recognize benchmark-private proxy headers, change server request-log formatting, or change configuration/public APIs.