feat(server): report declared model capabilities on /v1/models - #200
feat(server): report declared model capabilities on /v1/models#200elyasmnvidian wants to merge 1 commit into
Conversation
6b812fc to
538fb3d
Compare
WalkthroughThe change adds declared model capabilities for context-window size and tool calling. Route construction aggregates serving-target declarations, excludes classifier and judge targets, stores capabilities with routes, and exposes them through ChangesModel Capability Advertisement
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@crates/switchyard-server/src/capabilities.rs`:
- Around line 23-40: Extend ModelCapabilities and ModelCapabilities::for_models
to infer and store a tool_calling capability alongside context_window, using the
established default for empty routes and the least-capable result across
model_ids. Update downstream GET /v1/models serialization to use this field
instead of hard-coding tool support, and add coverage for a model that does not
support tool calling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d1483d77-6999-4092-b018-2090c7a0ded0
📒 Files selected for processing (4)
crates/switchyard-server/src/capabilities.rscrates/switchyard-server/src/config.rscrates/switchyard-server/src/lib.rscrates/switchyard-server/tests/server.rs
a87624c to
b02f431
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
b02f431 to
acf5ed6
Compare
Problem
GET /v1/modelsreportsnullfor every route'scontext_windowandtool_calling, and an operator has no way to change it. Take an operator running a route over a model they know has a 1M-token context window:What happens
GET /v1/modelslists the route with no capability values, so a client cannot learn the window from the listing:{ "id": "smart", "capabilities": { "streaming": true, "tool_calling": null, "context_window": null, "supported_inbound_formats": ["openai-chat-completions", "openai-responses", "anthropic-messages"] } }The route id (
smart) is an operator alias, not a model, so the server has nothing to read a real window from — and guessing one from the target model name breaks the moment a route serves a model the guess does not know.The fix
Let the operator declare each target's
context_windowandtool_callingin the server config. A route advertises the combination across the targets it can answer from: the smallest declared window (a route is only as capable as its most limited tier) and tool calling only when every tier supports it. A capability that no serving tier declares staysnull— the server never invents a number. A classifier or stage-router judge target only scores the request, so it is left out of the advertised capabilities.Evidence
Declared → the endpoint reports the value; undeclared → it stays null; one declared tier plus one undeclared tier → the route reports null rather than over-claiming the declared tier's window:
A declared
context_window = 0is rejected at config load. This is a config and contract change, so there is no performance number to report.How tested
capabilities.rsunit tests: smallest-window plus tool-calling combination; a tier without tool calling makes the route report false; a missing field reports null while the other field still combines; no serving targets reports null.config.rs: hints parse androute_capabilitiescombines them across serving tiers with the judge target excluded; a zerocontext_windowis rejected.tests/server.rs::models_endpoint_reports_declared_target_capabilities_and_null_when_undeclared: the full endpoint reports declared values, excludes the judge target, and reports null for undeclared and partially-declared routes.Compatibility
context_windowandtool_callingare new optional target fields. Existing configs keep working unchanged — a target that declares neither advertisesnull, exactly as today. No migration needed.Summary by CodeRabbit
New Features
Bug Fixes