chore(server): guard that /v1/models reports null model capabilities#105
chore(server): guard that /v1/models reports null model capabilities#105elyasmnvidian wants to merge 1 commit into
Conversation
WalkthroughThe server maps context exhaustion errors to HTTP 400 responses with an OpenAI-compatible error code. Model listings now expose tool-calling support and inferred context-window values, with integration tests covering both changes. ChangesServer behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/switchyard-server/tests/server.rs (1)
217-242: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover
ContextPoolExhaustedseparately.This test exercises only
ContextWindowExceeded, while the production mapping also handlesContextPoolExhausted. Add a profile/test for the second variant so regressions in that branch cannot pass unnoticed.🤖 Prompt for 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. In `@crates/switchyard-server/tests/server.rs` around lines 217 - 242, Add a separate test alongside context_window_overflow_maps_to_client_error using a profile that triggers ContextPoolExhausted. Send the same chat completion request through build_switchyard_router, then assert the response is BAD_REQUEST with error.code set to the expected client-facing code for pool exhaustion, covering the distinct production mapping branch.
🤖 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.
Nitpick comments:
In `@crates/switchyard-server/tests/server.rs`:
- Around line 217-242: Add a separate test alongside
context_window_overflow_maps_to_client_error using a profile that triggers
ContextPoolExhausted. Send the same chat completion request through
build_switchyard_router, then assert the response is BAD_REQUEST with error.code
set to the expected client-facing code for pool exhaustion, covering the
distinct production mapping branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 4f5c9536-37c6-407c-a66f-fcadc9be076c
📒 Files selected for processing (2)
crates/switchyard-server/src/lib.rscrates/switchyard-server/tests/server.rs
5a75be1 to
fe15312
Compare
| /// | ||
| /// Uses the same known-model fragments as the Python `model_listing` table: | ||
| /// the first matching substring wins, else a conservative 128k default. | ||
| fn inferred_context_window(model: &str) -> u32 { |
There was a problem hiding this comment.
Won't this be a symbolic / router name like smart or random? We don't advertise the upstream models any more.
f3d5269 to
50f24aa
Compare
Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
What
GET /v1/modelsleaves each model'scontext_windowandtool_callingasnull, and this PR keeps it that way on purpose, with a test that locks it in.Why
The
idin/v1/modelsis a symbolic route name (likerandomorsmart), not the upstream model behind it — so there's nothing to read a real context window or tool-calling flag from. Inferring one from the route name (or from a target) would be a guess, and a wrong one. The operator picks the models they route to and already knows their limits, so Switchyard doesn't need to advertise them.This replaces the earlier version of this PR, which inferred the context window from the model id and broke once the id became a route name (flagged in review).
Change
model_entry_jsonexplaining why the two fields arenull.randomover a big-context target and asserts both fields arenull— written so any future attempt to infer a value (from the route name or the target) fails the test.streamingand the supported inbound formats stay populated; those are facts about this server, not the upstream model.If someone later needs these reported, the operator can declare them in the server config and we report exactly what they set — no guessing.