feat(server): report declared model capabilities on /v1/models - #200
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.
|
b02f431 to
acf5ed6
Compare
|
@elyasmnvidian Should we declare this at the Maybe Slack thread? |
6bec5e3 to
e9ae317
Compare
|
|
@grahamking Done. I moved |
Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
e9ae317 to
c5c1950
Compare
With this config, the route has no way to declare its context window or tool support.
GET /v1/modelsreturns this entry:{ "id": "smart", "object": "model", "type": "model", "created": 0, "owned_by": "switchyard", "display_name": "smart", "capabilities": { "streaming": true, "tool_calling": null, "context_window": null, "supported_inbound_formats": [ "openai-chat-completions", "openai-responses", "anthropic-messages" ] } }Fix
context_windowandtool_callingbelong on the route because the route ID is the public model returned by/v1/models. Two routes can share a target and still advertise different settings.The same endpoint now reports:
{ "streaming": true, "tool_calling": true, "context_window": 1000000, "supported_inbound_formats": [ "openai-chat-completions", "openai-responses", "anthropic-messages" ] }These fields only describe the route; they do not enforce a request limit. Both are optional, so existing configs still return
null.The server rejects target-level declarations and a zero context window during config loading:
Routing and request handling are unchanged.
Test
The endpoint test gives three routes the same target. One route reports
true, one reportsfalse, and one leaves both fieldsnull.This is the operator-declared follow-up from #105.