Repository navigation
Add runtime model router route updates - #6835
Conversation
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
6f5f967 to
512ca65
Compare
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
512ca65 to
06f43c3
Compare
|
📁 PR Artifacts Notice This PR adds or changes temporary PR-specific documents under |
06f43c3 to
e07f796
Compare
7e6a552 to
8beddba
Compare
Co-authored-by: openhands <openhands@all-hands.dev>
8beddba to
39722c2
Compare
…outes # Conflicts: # openhands-agent-server/openhands/agent_server/conversation_router.py # openhands-agent-server/openhands/agent_server/event_service.py # openhands-agent-server/openhands/agent_server/models.py # openhands-agent-server/openhands/agent_server/server_details_router.py # tests/agent_server/test_server_details_router.py
Agent-server conversation start benchmarkBase
How this is measuredEach create is a Canvas-shaped
A timing is flagged when the 95% CIs do not overlap and the medians differ by at least 50 ms, or when a row with at least 8 samples per side moves by at least 150 ms and 25%. A create stalled the server when its slowest |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope gate: pass. The change sits squarely in this repository's ownership (Python SDK router, Agent Server REST endpoint, TypeScript client mirror, in the documented SDK → OpenAPI → clients/typescript flow). Linked issue #6860 is open, labeled enhancement/llm/sdk, and marked ready-for-dev; the PR's scope matches the issue's acceptance criteria, so no maintainer decision is needed.
Verification on head 29694c0c:
- All GitHub Actions checks pass for this exact head (REST API OpenAPI contract, persisted settings, endpoint audit, benchmark, sdk/agent-server/typescript suites included).
- Ran locally:
tests/sdk/llm/test_router_llm.py+tests/sdk/conversation/test_switch_model.py(51 passed),tests/agent_server/test_conversation_router.py+test_server_details_router.py(145 passed), TypeScriptapi-clients.test.ts(103 passed), plusnpm run buildandnpm run lint(0 errors; the 5 warnings are pre-existing in files this PR does not touch). - Exercised the real runtime path on a
LocalConversation(throwaway script, deleted afterward): starting from a plain LLM,add_model_router_routewraps the agent LLM into aRouterLLMwith routes[default, reviewer]; a second route extends the existing router; duplicate route names are rejected with a clearValueError; manual switch and return-to-auto updateselectioncorrectly; registry identity is preserved (profile:<name>resolves to the installed route LLM); the persisted-state round-trip keeps the route snapshot taken at install time; missing profiles raiseFileNotFoundError.
Cross-layer checks: the new POST /model_router/routes endpoint is additive (OpenAPI contract check green) and advertised via the conversation_model_router_routes_v1 capability; EventService.add_model_router_route delegates to the conversation on an executor and publishes a state update, mirroring add_mcp_servers, and its ValueError("inactive_service") matches the documented ServiceInactive type/message contract; except ValueError → 400 mirrors the existing add_mcp_servers route. RemoteConversation gains the full model-router surface (get_model_router, add_model_router_route, selection update/switch/auto), closing the previous gap where the PATCH /model_router endpoint had no Python remote client method. LLM registration after the swap (_register_agent_llms) follows the same policy as conversation-init registration. Existing switch_llm/switch_profile behavior is untouched, matching the issue's non-goal, and no persisted-settings schema migration is involved.
No dependency changes (seven-day release-age policy not triggered). One eval note for the human maintainer, not a defect: this adds a new routing API surface; the benchmark and behavior checks pass, and the PR includes a downstream Agent Canvas manual-switching video, but per the review guide the maintainer may opt for a lightweight evaluation if desired.
No material correctness, security, compatibility, or acceptance-criterion defects found.
✅ APPROVED
…store Main gained two profile loads that pass the cipher per call: LocalConversation.add_model_router_route (#6835) and resolution_judge (#6962). The conversation's store and the server's store are bound to their cipher, so both now load and save without naming it. resolution_judge(cipher=...) was published in 1.63.0. It stays as a deprecated argument that binds the store, scheduled for removal in 1.70.0.
HUMAN:
Tested downstream in agent canvas; created model router mid conversation and performed manual switches (as per video below)
AGENT:
Why
This stacks on PR 6789. It adds the runtime route-addition path needed for clients to start a conversation with a plain LLM, add another LLM through the model-router API, and then manually switch routes without using the deprecated whole-LLM switch endpoint.
Summary
ConfigurableRouterplusRouterLLM.with_route(...), and teachesLocalConversation.add_model_router_route(...)to wrap a plain LLM into a router when needed.POST /api/conversations/{id}/model_router/routes, EventService support, server capability advertising, and Python/TypeScript remote client helpers.REST API contract changes
Compared with base OpenAPI
001a75e50778for public/api/**paths.Issue Number
Refs #6860. Stacked on PR 6789.
How to Test
uv run pytest tests/sdk/llm/test_router_llm.py tests/sdk/conversation/test_switch_model.py tests/agent_server/test_conversation_router.py tests/agent_server/test_server_details_router.py -quv run pre-commit run --files .pr/model-router-design.html clients/typescript/src/__tests__/api-clients.test.ts clients/typescript/src/client/conversation-client.ts clients/typescript/src/conversation/conversation-manager.ts clients/typescript/src/conversation/remote-conversation.ts openhands-agent-server/openhands/agent_server/conversation_router.py openhands-agent-server/openhands/agent_server/event_service.py openhands-agent-server/openhands/agent_server/models.py openhands-agent-server/openhands/agent_server/server_details_router.py openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py openhands-sdk/openhands/sdk/conversation/impl/remote_conversation.py openhands-sdk/openhands/sdk/llm/__init__.py openhands-sdk/openhands/sdk/llm/router/__init__.py openhands-sdk/openhands/sdk/llm/router/base.py openhands-sdk/openhands/sdk/llm/router/impl/configurable.py tests/agent_server/test_conversation_router.py tests/agent_server/test_server_details_router.py tests/sdk/conversation/test_switch_model.py tests/sdk/llm/test_router_llm.pycd clients/typescript && npm test -- src/__tests__/api-clients.test.tscd clients/typescript && npm run lint && npm run build && npm run format:checkVideo/Screenshots
Screen.Recording.2026-11-14.at.2.53.58.PM.mov
Design Doc
https://htmlpreview.github.io/?https://github.com/OpenHands/software-agent-sdk/blob/feat/runtime-model-router-routes/.pr/model-router-design.html
Type
Notes
This PR was created by an AI agent (OpenHands) on behalf of the user.
@malhotra5 can click here to continue refining the PR
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:29694c0-pythonRun
All tags pushed for this build
About Multi-Architecture Support
29694c0-python) is a multi-arch manifest supporting both amd64 and arm6429694c0-python-amd64) are also available if needed