Skip to content

feat(serve): route the model of a new server session - #971

Merged
ajianaz merged 4 commits into
developfrom
feat/server-routing
Nov 19, 2026
Merged

ajianaz merged 4 commits into
developfrom
feat/server-routing

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Capability 2 of #945 (step 4 of epic #941): model routing (#586) for server sessions (tole serve, tole acp, MCP session tools).

Why

Routing was CLI-only (a drift #945 row in docs/faces.md). A server session has no prompt at creation, so it must be routed at its first prompt, with the CLI's semantics.

Changes

  • session/host.rs: run_session_turn_detailed (the one path serve, acp and the MCP session tools share) calls the existing assemble::route_session once, at the first prompt of a new session, before any provider call. Skipped when the session already has a model (a profile's, or fact/model set by the client through POST /sessions/{id}/model) and for a resumed session (first_prompt_done starts true). The owner's user config is read at that point; a request cannot add tiers or rules or enable routing. A router error or a user config that no longer loads fails that prompt, redacted, before any provider call.
  • Only fact/model and the redacted fact/route change.
  • docs/faces.md: the routing row becomes one path; docs/threat-model.md routing row extended; CHANGELOG entry (Behavior change).
  • New tests/serve_routing_e2e.rs.

Testing

  • New e2e tests (real tole serve): off by default, first prompt routed with fact/route recorded, same tools with and without a route, second prompt not re-routed, client-set model not overridden, resume not re-routed, broken router errors before any provider call, error redaction.
  • cargo fmt --all; clippy -D warnings in the default, --no-default-features and --no-default-features --features shell-tools profiles; full cargo test -p tole-cli (1634 passed, 0 failed); face_parity also checked to still fail on a temporary mutation of a docs row (reverted).

false,
None,
)
.map_err(|e| e.to_string())
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

ajianaz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Cora's finding on host.rs:585 does not apply: assemble::route_session redacts its own error with the process secrets (assemble.rs, .map_err(|e| anyhow::anyhow!(secrets.redact(&e).into_owned()))) before it returns, so the e.to_string() in route_first_prompt already carries redacted text. Nothing leaks. I added a comment at that site (f21afe4) so the redaction point is explicit, and no behavior changed.


Generated by Claude Code

@ajianaz
ajianaz merged commit 642174f into develop Nov 19, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/server-routing branch November 20, 2026 08:37
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.

2 participants