Skip to content

Elevate conversation LLM switching into the model router #6860

Closed

Description

@malhotra5

Problem

OpenHands currently has conversation-level LLM switching APIs that replace the active LLM object directly. That makes manual model switching a separate path from model routing, and keeps the UI/API tied to LLM profiles even as the SDK moves toward router-owned model selection.

We want the model router to own LLM selection state so OpenHands can eventually deprecate the direct switch_llm / switch_profile route family and expose switching through the model-router API instead.

Desired outcome

  • A conversation can report model-router state through a first-class API.
  • A router-backed conversation can switch manually to a route and return to automatic routing without replacing the active LLM object.
  • A conversation that starts with a plain LLM can add routes at runtime so clients can build a model-router flow incrementally.
  • Existing switch APIs remain compatible while the router-based API is evaluated.
  • Python SDK, Agent Server REST API, and TypeScript client entry points stay aligned.

Acceptance criteria

  • RouterLLM exposes serializable state for current routing mode, selected route, and available routes.
  • Local and remote conversation APIs can read/update router selection.
  • Agent Server exposes additive model-router endpoints for status, selection updates, and runtime route addition.
  • TypeScript client helpers cover the new REST API surface.
  • Tests cover plain LLMs, router-backed LLMs, duplicate route handling, manual switching, returning to auto routing, and server/client API behavior.

Related PRs

This issue was created by an AI agent (OpenHands) on behalf of the user.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

On main, RouterLLM (openhands-sdk/openhands/sdk/llm/router/base.py) currently only auto-selects via select_llm() and exposes no routing-mode/selected-route state, while LocalConversation switching goes through switch_llm / switch_profile, which replace the agent's LLM object. The referenced PRs #6789 (router-owned routing mode and manual switch state, additive GET/PATCH /api/conversations/{conversation_id}/model_router endpoints, TypeScript helpers) and #6835 (stacked: ConfigurableRouter, with_route(...), runtime route addition via POST /api/conversations/{conversation_id}/model_router/routes, capability advertising) already establish the design this issue formalizes, so the scope is resolvable from repository evidence and the criteria below make the issue startable independently of those drafts.

Bounded scope: make the router own manual/auto selection state and expose it through the conversation, Agent Server REST, and TypeScript client layers, additively. Non-goals: no deprecation or removal of the existing switch_llm / switch_profile APIs in this change; no new routing-selection strategies beyond exposing existing router state; no Agent Canvas UI work (owned by OpenHands/OpenHands per AGENTS.md); no changes to persisted settings schema versions or migration chains.

Acceptance Criteria

  • RouterLLM exposes serializable state for current routing mode, selected route, and available routes (visible in RouterLLM.model_dump() output), and a router deserialized from that output preserves the same routing mode, selected route, and routes (covered in tests/sdk/llm/test_router_llm.py).
  • LocalConversation reads the router's routing mode/selected route without mutating the agent's LLM object: after a manual switch, the agent instance identity is unchanged and a subsequent completion is routed to the selected route; switching back to automatic routing restores router-driven selection (covered in tests/sdk/conversation/test_switch_model.py).
  • RemoteConversation exposes equivalent read/update operations for router selection against the Agent Server, matching the local API surface.
  • A conversation started with a plain LLM (non-router) accepts runtime route addition: after adding a route it reports router-backed state and supports manual switching; adding a route whose key already exists is rejected with a well-defined error rather than silently overwriting.
  • Agent Server exposes additive endpoints for router status, selection updates, and runtime route addition that appear in the public OpenAPI contract, and server capabilities advertise the new endpoints; a conversation without a router-backed LLM returns a well-defined 404-style response instead of a 500 (covered in tests/agent_server/test_conversation_router.py and tests/agent_server/test_server_details_router.py).
  • TypeScript client helpers in clients/typescript cover the new REST endpoints (status read, selection update, route addition) with tests in clients/typescript/src/__tests__/api-clients.test.ts.
  • Existing switch_llm / switch_profile behavior is unchanged: the pre-existing tests in tests/sdk/conversation/test_switch_model.py pass without modification.

Activity

  1. added
    enhancement
    llm
    ready-for-dev
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementllmready-for-devsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions