openclaw - 💡(How to fix) Fix Feature: Per-task model routing (route simple tasks to cheaper models) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#56125Fetched 2026-04-08 01:44:38
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Allow OpenClaw to route messages to different models based on task complexity, skill, or explicit configuration — so simple tasks (weather, reminders, smart home, basic Q&A) use a cheaper/faster model like Haiku while complex tasks (research, coding, financial analysis) use Sonnet or Opus.

Root Cause

Allow OpenClaw to route messages to different models based on task complexity, skill, or explicit configuration — so simple tasks (weather, reminders, smart home, basic Q&A) use a cheaper/faster model like Haiku while complex tasks (research, coding, financial analysis) use Sonnet or Opus.

Code Example

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-6",
        "fallbacks": ["anthropic/claude-opus-4-6"],
        "routing": {
          "rules": [
            {
              "match": {"skills": ["weather", "openhue", "sonoscli", "blucli", "eightctl", "apple-reminders", "apple-notes"]},
              "model": "anthropic/claude-haiku-4-5"
            },
            {
              "match": {"thinking": "max"},
              "model": "anthropic/claude-opus-4-6"
            }
          ]
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

Allow OpenClaw to route messages to different models based on task complexity, skill, or explicit configuration — so simple tasks (weather, reminders, smart home, basic Q&A) use a cheaper/faster model like Haiku while complex tasks (research, coding, financial analysis) use Sonnet or Opus.

Use Case

I run an always-on OpenClaw instance on a Mac mini managing 3 live SaaS products, an investment platform, and a custom research bot (Sentinel). My primary interface is Telegram with ~100+ interactions/day.

Current state: Every message hits Claude Sonnet 4.6 ($3/$15 per MTok) regardless of complexity — "turn on the lights" costs the same as "analyze this SEC filing."

Desired state: Simple tasks route to Haiku 4.5 ($1/$5) automatically, with Sonnet as default and Opus for explicitly complex work.

Estimated savings: 60-70% of my Telegram traffic is simple Q&A/commands. Routing those to Haiku would save ~$60/month on a ~$300/month bill.

Proposed Config

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-6",
        "fallbacks": ["anthropic/claude-opus-4-6"],
        "routing": {
          "rules": [
            {
              "match": {"skills": ["weather", "openhue", "sonoscli", "blucli", "eightctl", "apple-reminders", "apple-notes"]},
              "model": "anthropic/claude-haiku-4-5"
            },
            {
              "match": {"thinking": "max"},
              "model": "anthropic/claude-opus-4-6"
            }
          ]
        }
      }
    }
  }
}

Alternative approaches that would also work:

  • A /model slash command to set per-session model (like /think sets thinking level)
  • Skill-level model override in skill config
  • A lightweight Haiku classifier that picks the model before the main call

Context

  • OpenClaw version: 2026.3.23-2
  • 38 skills active, many are simple command-response patterns
  • Already using task-specific MCP configs (mcp-coding.json, mcp-financial.json, mcp-research.json) for tool routing — model routing is the natural next step
  • Anthropic pricing: Opus $5/$25, Sonnet $3/$15, Haiku $1/$5 per MTok

Impact

This would be valuable for any OpenClaw user running always-on with high message volume. The cost difference between routing everything through Sonnet vs intelligently splitting across 3 models is 40-60%.

extent analysis

Fix Plan

To implement model routing based on task complexity, we will modify the OpenClaw configuration to include routing rules.

Here are the steps:

  • Update the config.json file with the proposed configuration:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-6",
        "fallbacks": ["anthropic/claude-opus-4-6"],
        "routing": {
          "rules": [
            {
              "match": {"skills": ["weather", "openhue", "sonoscli", "blucli", "eightctl", "apple-reminders", "apple-notes"]},
              "model": "anthropic/claude-haiku-4-5"
            },
            {
              "match": {"thinking": "max"},
              "model": "anthropic/claude-opus-4-6"
            }
          ]
        }
      }
    }
  }
}
  • Add a new function to determine the model based on the routing rules:
def get_model(skill, thinking_level):
    # Define the routing rules
    rules = [
        {"match": {"skills": ["weather", "openhue", "sonoscli", "blucli", "eightctl", "apple-reminders", "apple-notes"]}, "model": "anthropic/claude-haiku-4-5"},
        {"match": {"thinking": "max"}, "model": "anthropic/claude-opus-4-6"}
    ]
    
    # Iterate over the rules and return the model if a match is found
    for rule in rules:
        if "skills" in rule["match"] and skill in rule["match"]["skills"]:
            return rule["model"]
        elif "thinking" in rule["match"] and thinking_level == rule["match"]["thinking"]:
            return rule["model"]
    
    # Return the primary model if no match is found
    return "anthropic/claude-sonnet-4-6"
  • Update the message processing function to use the get_model function:
def process_message(message):
    skill = message["skill"]
    thinking_level = message["thinking_level"]
    model = get_model(skill, thinking_level)
    # Use the selected model to process the message
    # ...

Verification

To verify that the fix worked, you can test the message routing by sending different types of messages and checking which model is used. You can also monitor the costs and compare them to the estimated savings.

Extra Tips

  • Make sure to update the config.json file correctly and restart the OpenClaw instance after making changes.
  • You can add more routing rules and models as needed to further optimize the cost and performance.
  • Consider implementing a feedback

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING