Skip to content

feat(libsy): include session id in decision context - #1141

Open
alexn-ac wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
alexn-ac:feature/decision-context-session
Open

alexn-ac wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
alexn-ac:feature/decision-context-session

Conversation

@alexn-ac

@alexn-ac alexn-ac commented Oct 24, 2026 •

Copy link
Copy Markdown

What

The llm_classifier decision client now sends the request's session ID in the decision context, as session. The value is null when the request has no session ID.

Why

An external decision service may keep state for each conversation, such as a cache of earlier turns. To do that, it needs a stable key for the conversation. Switchyard already reads the session ID from client headers, such as x-claude-code-session-id and Codex's x-codex-turn-metadata. Before this change, the decision service could not see it.

Notes for reviewers

  • The change is one line in crates/libsy/src/algorithms/llm_class/decision.rs.
  • crates/switchyard-server/CONFIGURATION.md documents the new field.
  • Tests: the libsy exact-context test now expects session. The runner openai_decisions test sends a request with a session ID and checks that it reaches the decision endpoint.
  • I also checked it end to end through switchyard-server with mock backends. The session ID arrived for both Claude Code and Codex requests.
  • Local checks: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, uv run ruff check ., uv run mypy switchyard and uv run pytest tests/ all pass.

Summary by CodeRabbit

  • Improvements
    • Decision context now includes the request’s session ID, or null when no session ID is available.
  • Documentation
    • Clarified that session information is included in decision context.

Signed-off-by: alexn-ac <alexn@appliedcompute.com>
@alexn-ac
alexn-ac requested a review from a team as a code owner October 24, 2026 03:24
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 62efb77 and 3e90412.

Files selected for processing: 4
  • crates/libsy/src/algorithms/llm_class.rs
  • crates/libsy/src/algorithms/llm_class/decision.rs
  • crates/switchyard-runner/tests/openai_decisions.rs
  • crates/switchyard-server/CONFIGURATION.md

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The decision judge context now includes the request’s session ID, or null when no session ID is available. Tests check the serialized context, and the configuration documentation describes the field.

Changes

Decision Context

Layer / File(s) Summary
Add session ID to judge context
crates/libsy/src/algorithms/llm_class/decision.rs, crates/switchyard-runner/tests/openai_decisions.rs, crates/libsy/src/algorithms/llm_class.rs, crates/switchyard-server/CONFIGURATION.md
The judge context includes the request’s session ID, or null when it is absent. Tests check the serialized session ID, and the configuration documentation describes the context field.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: Minimal · up to 3e904

The session field is documented and covered by focused serialization and routing tests; no actionable merge risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding the session ID to the decision context.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the session trail
And finds its ID inside the tale
If none is set, then null appears
The test confirms what context hears
The docs record it, crisp and clear

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant