Skip to content

fix(llm-client): forward caller session headers - #1402

Open
ryan-lempka wants to merge 1 commit into
mainfrom
fix/forward-session-identity
Open

ryan-lempka wants to merge 1 commit into
mainfrom
fix/forward-session-identity

Conversation

@ryan-lempka

@ryan-lempka ryan-lempka commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

A gateway that uses X-Session-Id for affinity can keep a conversation on the endpoint holding its prompt cache. Switchyard now passes through the caller's header even when it uses its own upstream credentials. Callers can keep the header local to the inbound connection by listing it in Connection.

Signed-off-by: Ryan Lempka <rlempka@nvidia.com>
@ryan-lempka
ryan-lempka requested a review from a team as a code owner November 26, 2026 14:53
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.2

🚀 View preview at
https://NVIDIA-NeMo.github.io/Switchyard/pr-preview/pr-1402/

Built to branch gh-pages at 2026-11-26 14:55 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The client now allows x-session-id in metadata-header forwarding. It applies non-forwardable-header checks after auth-forwarding or allowlist selection. Tests cover forwarding and rejection when Connection names x-session-id. The README documents the default forwarding behavior.

Changes

Metadata Header Forwarding

Layer / File(s) Summary
Metadata header selection and filtering
crates/libsy-llm-client/src/client.rs, crates/libsy-llm-client/README.md
The safe allowlist adds x-session-id. Non-forwardable-header checks now apply after auth-forwarding or allowlist selection. Tests cover forwarding x-session-id and rejecting it when the inbound Connection header names it. The README documents forwarding x-request-id and x-session-id unless marked connection-specific.

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

Merge Risk: Minimal · up to 6462a

Switchyard now forwards the caller's X-Session-Id header upstream by default, except when the caller marks it connection-specific. No merge-blocking risk was found.

Security architecture risk: Low · up to 6462a

Upstreams can now link requests that carry the same caller-supplied session identifier. The change does not let callers replace backend credentials, and there is no evidence that a receiving service uses the identifier to grant access to another caller’s session.

Retained concerns

  • Low · security · inferred: Configured-key upstreams now receive an unbound, caller-chosen conversation identifier. A receiver can correlate matching identifiers, and a receiver that uses the identifier alone to select shared conversation state could confuse sessions across callers. No such stateful receiver was confirmed.
Security review details

Security Blast Radius

  • inferred — The new exposure applies to callers who can already reach a configured-key route and supply request metadata. It covers completion and model-bearing auxiliary requests that use the shared sender. The deployed upstreams, affected tenant population, and any redirect recipients are unverified.

Trust Boundaries and Controls

  • observed — The connection-specific filter checks every Connection field and compares comma-separated tokens case-insensitively. It controls transport forwarding, not whether the caller owns the supplied session identifier.

Hardening Proposals

  • proposed — Before enabling forwarding to a stateful upstream, verify that session lookup is scoped to an authenticated principal or tenant. Consider per-backend opt-in where that guarantee is unavailable or the upstream does not need the identifier.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(llm-client): forward caller session headers" matches the main change. The PR adds x-session-id to the safe metadata-header allowlist, so the client forwards caller session headers. The …
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(llm-client): forward caller session headers" matches the main change. The PR adds x-session-id to the safe metadata-header allowlist, so the client forwards caller session headers. The changeset also adds checks against non-forwardable and Connection-named hop-by-hop headers, and updates the README. The title covers the primary change and states it in one short, specific sentence. The title is conventional and its scope prefix names the affected crate.

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

A rabbit checks the headers in a row.
“x-session-id may safely go.”
If Connection names it, hold it back.
The tests confirm each forwarding track.
The README tells what headers flow.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 435d3b9 and 6462af7.

Files selected for processing: 2

  • crates/libsy-llm-client/README.md
  • crates/libsy-llm-client/src/client.rs

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

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