Skip to content

Trajectory pinning (via session_id) for consistent model selection in routing#827

Open
adilhafeez wants to merge 5 commits intomainfrom
plano-session_pinning
Open

Trajectory pinning (via session_id) for consistent model selection in routing#827
adilhafeez wants to merge 5 commits intomainfrom
plano-session_pinning

Conversation

@adilhafeez
Copy link
Copy Markdown
Contributor

@adilhafeez adilhafeez commented Mar 14, 2026

Summary

Closes #813

  • Adds X-Session-Id header support to the /routing/v1/* endpoints. When provided, the first routing decision is cached and subsequent requests with the same session ID return the pinned model without re-running routing.
  • In-memory TTL cache with configurable session_ttl_seconds (default 600s) and session_max_entries (default 10,000) via routing config section.
  • Response includes session_id and pinned fields to indicate cache status. No breaking changes — requests without the header behave as before.

@salmanap
Copy link
Copy Markdown
Contributor

The test case that would prove this is an agentic loop. Can you build some test cases for that and test with live clients like anthropic and/or openai?

@nehcgs please review. The idea is that if the model is not done, we should pin the agentic loop to a single model until we get the [done] flag from the model, at which point we can resume our model routing logic.

@salmanap salmanap changed the title Support session pinning for consistent model selection in routing Trajectory pinning (via session_id) for consistent model selection in routing Mar 15, 2026
- extend brightstaff llm_chat_inner to extract X-Session-Id, check the
  session cache before routing, and cache the result afterward — same
  pattern as routing_service.rs
- replace old urllib-based demo with a real FastAPI research agent that
  runs 3 independent tool-calling tasks with alternating intents so
  Plano routes to different models; demo.py is a pure httpx client that
  shows the routing trace side-by-side with and without session pinning
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.

Support trajectory pinning for consistent model selection in agentic loops

2 participants