A ready-to-run example is available here!The
route_task_to_model tool (a.k.a. ClassifyAndSwitchLLMTool) lets an agent
start on a default LLM profile and switch to a better-suited profile per task.
When the agent calls the tool, a lightweight classifier LLM inspects the
recent conversation, picks the most suitable saved LLM profile for the task, and
switches the conversation to that profile before the agent continues.
A meta-profile declaratively describes how to classify a task. It supports
two shapes:
- Structured classes — a fixed set of
{description, model}rows; the classifier returns a class index. - Direct prompt — a
prompt_templaterendered with{{ instance_text }}and{{ model_table }}; the classifier returns the model name directly as JSON. This is the shape used by the Pareto prompt meta-profiles.
meta_profile_llms.
Wiring the tool through settings
Enable the tool and set the active meta-profile onOpenHandsAgentSettings —
that is all it takes to wire route_task_to_model into the agent:
Structured-classes meta-profile
The classifier returns a 1-based class index;model is the saved profile name
to switch to. classifier_model is itself a saved profile name used to run the
classification call.
Direct-prompt meta-profile
Instead of fixed classes, give the classifier a free-form prompt template and a model table. The classifier returns the model name directly as JSON{"model": "<name>", "reason": "..."}.
Ready-to-run Example
This example is available on GitHub: examples/01_standalone_sdk/59_route_task_to_model.py
route_task_to_model
tool, demonstrating both the structured-classes and direct-prompt meta-profile
shapes:
examples/01_standalone_sdk/59_route_task_to_model.py
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Next Steps
- Model Routing — Route requests based on content (e.g., multimodal vs text-only)
- LLM Profile Store — Save and load reusable LLM configurations
- LLM Metrics — Track token usage and costs

