feat(api): honor provider-aware request routing - #54426
abundantbeing wants to merge 7 commits into
Conversation
Related to #52531 (a closed earlier attempt at the same authenticated |
|
Follow-up after triage pointed at #52531 / #40563 / #14352: I re-ran this request path as a failing smoke first. Before the follow-up commit,
I then restored the missing behavior from the earlier closed attempt (#52531): API requests now carry Fresh verification after the new commit:
So this PR is no longer just the inventory endpoint; it now covers the display + actual request execution path. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for carrying the inventory endpoint forward. The endpoint is still absent from the gateway API server on current main, so the feature remains useful.
Problems
- This branch predates
model_routes(4a09b69). Current main resolves configured routes in Chat/Responses and applies route credentials ingateway/platforms/api_server.py:1320-1363. Please integrate request overrides with that pipeline and define precedence against a session/modeloverride. /v1/runsis a separate agent-entry path: it resolves onlymodel_routesand directly calls_create_agent(gateway/platforms/api_server.py:4336-4361). The PR does not propagateproviderormodel_optionsthere.- The advertised API needs docs; current endpoint references omit
/api/model/options(website/docs/user-guide/features/api-server.md:197-222).
Suggested changes
- Add precedence and end-to-end coverage across session chat, Chat Completions, Responses, and Runs.
- Document the authenticated endpoint and capability flag.
Automated hermes-sweeper review.
# Conflicts: # gateway/platforms/api_server.py
|
Updated against current
Verification on branch head
The one deselected health-detail assertion is environment-sensitive and reproduces on current-main-based lanes; it is unrelated to this routing diff. Ready for re-review. |
|
Proposed merge topology so the routing PRs do not diverge:
Combined precedence should be:
One edge case should be decided explicitly: a My intended merge order is #54426 before #61236, followed by rebasing #61236 onto the accepted resolver shape. |
# Conflicts: # gateway/platforms/api_server.py
|
Refreshed against current upstream Scope remains execution routing only. The resolution preserves current-main profile scoping, checkpoint kwargs, Fresh verification:
GitHub now reports this head as mergeable. #54689 combines cleanly with it. This should merge before #61236 so the durable-lock PR can take one final refresh onto the accepted resolver. |
Carry model, provider, and model_options through the API server's execution surfaces (session chat, Chat Completions, Responses, /v1/runs) without mutating global configuration. Precedence: session /model override -> model_routes alias -> direct request selection -> global defaults. Conflicting route/provider mixes fail closed with 400. model_options stays request-scoped regardless of which selection wins. Salvaged from PR #54426 by @abundantbeing.
Follow-ups on the salvaged #54426 routing contract: - Bare `model` without `provider` on the OpenAI-compatible endpoints (/v1/chat/completions, /v1/responses) is now opt-in via gateway.platforms.api_server.direct_model_requests (default off) — generic OpenAI clients hardcode model names ('gpt-4o', ...) and existing deployments rely on those falling back to the gateway default. Explicit `provider` requests and the Hermes-native session-chat + /v1/runs surfaces are always honored. Idea credit: PR #22825 by @mssteuer. - A model_routes alias with no `model` key can no longer leak the alias string as the executing model name (defensive; parse-time validation already drops such routes). - Fix mis-indented _run_agent call args in _handle_session_chat_stream. - Docs: document the opt-in flag.
|
Merged via PR #70853 — your commits were reapplied onto current One follow-up we added on top: bare #61236 can now rebase onto the merged resolver shape as you proposed. |
Carry model, provider, and model_options through the API server's execution surfaces (session chat, Chat Completions, Responses, /v1/runs) without mutating global configuration. Precedence: session /model override -> model_routes alias -> direct request selection -> global defaults. Conflicting route/provider mixes fail closed with 400. model_options stays request-scoped regardless of which selection wins. Salvaged from PR NousResearch#54426 by @abundantbeing.
Follow-ups on the salvaged NousResearch#54426 routing contract: - Bare `model` without `provider` on the OpenAI-compatible endpoints (/v1/chat/completions, /v1/responses) is now opt-in via gateway.platforms.api_server.direct_model_requests (default off) — generic OpenAI clients hardcode model names ('gpt-4o', ...) and existing deployments rely on those falling back to the gateway default. Explicit `provider` requests and the Hermes-native session-chat + /v1/runs surfaces are always honored. Idea credit: PR NousResearch#22825 by @mssteuer. - A model_routes alias with no `model` key can no longer leak the alias string as the executing model name (defensive; parse-time validation already drops such routes). - Fix mis-indented _run_agent call args in _handle_session_chat_stream. - Docs: document the opt-in flag.
Carry model, provider, and model_options through the API server's execution surfaces (session chat, Chat Completions, Responses, /v1/runs) without mutating global configuration. Precedence: session /model override -> model_routes alias -> direct request selection -> global defaults. Conflicting route/provider mixes fail closed with 400. model_options stays request-scoped regardless of which selection wins. Salvaged from PR NousResearch#54426 by @abundantbeing.
Follow-ups on the salvaged NousResearch#54426 routing contract: - Bare `model` without `provider` on the OpenAI-compatible endpoints (/v1/chat/completions, /v1/responses) is now opt-in via gateway.platforms.api_server.direct_model_requests (default off) — generic OpenAI clients hardcode model names ('gpt-4o', ...) and existing deployments rely on those falling back to the gateway default. Explicit `provider` requests and the Hermes-native session-chat + /v1/runs surfaces are always honored. Idea credit: PR NousResearch#22825 by @mssteuer. - A model_routes alias with no `model` key can no longer leak the alias string as the executing model name (defensive; parse-time validation already drops such routes). - Fix mis-indented _run_agent call args in _handle_session_chat_stream. - Docs: document the opt-in flag.
Carry model, provider, and model_options through the API server's execution surfaces (session chat, Chat Completions, Responses, /v1/runs) without mutating global configuration. Precedence: session /model override -> model_routes alias -> direct request selection -> global defaults. Conflicting route/provider mixes fail closed with 400. model_options stays request-scoped regardless of which selection wins. Salvaged from PR NousResearch#54426 by @abundantbeing.
Follow-ups on the salvaged NousResearch#54426 routing contract: - Bare `model` without `provider` on the OpenAI-compatible endpoints (/v1/chat/completions, /v1/responses) is now opt-in via gateway.platforms.api_server.direct_model_requests (default off) — generic OpenAI clients hardcode model names ('gpt-4o', ...) and existing deployments rely on those falling back to the gateway default. Explicit `provider` requests and the Hermes-native session-chat + /v1/runs surfaces are always honored. Idea credit: PR NousResearch#22825 by @mssteuer. - A model_routes alias with no `model` key can no longer leak the alias string as the executing model name (defensive; parse-time validation already drops such routes). - Fix mis-indented _run_agent call args in _handle_session_chat_stream. - Docs: document the opt-in flag.
Summary
Honor provider-aware
model,provider, andmodel_optionsfields across the API server's execution surfaces without mutating global configuration.This branch now focuses only on execution-time routing. The provider/model inventory endpoint is isolated in #54689 so the two PRs no longer carry competing implementations.
Routing contract
Selection precedence is explicit and consistent:
/modeloverride wins for that session.modelmatches a configuredgateway.platforms.api_server.model_routesalias, the route's target and credentials are used.model/providervalues are resolved through the authenticated provider runtime.model_optionsremains request-scoped regardless of which model/provider selection wins. A request provider that conflicts with a pinned route provider or route credentials fails closed with400rather than mixing credentials across providers.Changes
model,provider, andmodel_optionsthrough session chat, Chat Completions, Responses, and/v1/runsmodel_routestarget models, provider runtimes, route-specific API keys, and base URLs/modelselection and its provider/runtime credentials ahead of per-request selectionAIAgentVerification