openclaw - 💡(How to fix) Fix Feature Request: Automatic Model Switching (Smart Routing) [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#56910Fetched 2026-04-08 01:46:11
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Error Message

  • Deep tier triggers: Multi-step reasoning requests, "think about", "analyze", "debug", architecture discussions, error diagnosis with large context.

Code Example

routing:
  tiers:
    fast:
      model: claude-haiku-3.5
      description: Simple responses, acknowledgments, quick lookups
    standard:
      model: claude-sonnet-4
      description: Routine tasks, file edits, searches
    deep:
      model: claude-opus-4
      description: Complex reasoning, architecture, debugging
  floor: standard           # never route below this tier
  classifier: heuristic     # or "model" for LLM-based classification
RAW_BUFFERClick to expand / collapse

Feature Request: Automatic Model Switching (Smart Routing)

Problem Statement

OpenClaw uses a single model for all messages in a session. Simple acknowledgments ("yes", "do it", "thanks") consume the same expensive tokens as complex reasoning tasks. Cost-conscious users constantly /model switch between cheap and expensive models, adding friction and breaking flow.

Proposed Solution

Model Tiers

routing:
  tiers:
    fast:
      model: claude-haiku-3.5
      description: Simple responses, acknowledgments, quick lookups
    standard:
      model: claude-sonnet-4
      description: Routine tasks, file edits, searches
    deep:
      model: claude-opus-4
      description: Complex reasoning, architecture, debugging
  floor: standard           # never route below this tier
  classifier: heuristic     # or "model" for LLM-based classification

Classification Heuristics

  • Fast tier triggers: Short messages (<20 tokens), affirmative responses, simple questions with obvious answers.
  • Deep tier triggers: Multi-step reasoning requests, "think about", "analyze", "debug", architecture discussions, error diagnosis with large context.
  • Standard: Everything else (default).

User Controls

  • Per-message override: /deep prefix forces deep model for next message.
  • Floor setting: "Never go below standard" for users who prefer quality over cost.
  • Transparency: Show which tier handled each response (subtle indicator).
  • Cost dashboard: Track savings from auto-routing vs. single-model usage.

User Impact

  • Cost reduction: 40-60% savings estimated for typical usage patterns where many messages are simple.
  • Zero friction: Users stop thinking about model selection entirely.
  • Quality preserved: Complex tasks still get the most capable model.
  • Always-on viability: Lower average cost makes 24/7 agent usage more affordable.

Technical Considerations

  • Classification latency: Must be near-zero. Heuristic approach (regex + token count) is fastest; LLM-based classification adds a round-trip.
  • Context transfer: Mid-conversation model switches must carry full context. Already handled by the gateway's provider abstraction.
  • Ambiguous messages: Conservative routing (default up) is safer than misrouting complex tasks to cheap models.
  • Feedback loop: Track user corrections (manual overrides after auto-route) to improve heuristics over time.
  • Interaction with fallback chains: Routing and fallback are independent; a routed-to model can still fall back to its tier's alternative.

Priority

MEDIUM-HIGH. Cost is the #1 barrier to always-on agent usage. This feature directly attacks it without compromising quality. Implementation complexity is moderate — heuristic routing can ship quickly, with LLM-based classification as a future enhancement.

extent analysis

Fix Plan

To implement automatic model switching, follow these steps:

  1. Define model tiers: Create a configuration file (e.g., model_tiers.yaml) with the following structure:
routing:
  tiers:
    fast:
      model: claude-haiku-3.5
      description: Simple responses, acknowledgments, quick lookups
    standard:
      model: claude-sonnet-4
      description: Routine tasks, file edits, searches
    deep:
      model: claude-opus-4
      description: Complex reasoning, architecture, debugging
  floor: standard
  classifier: heuristic
  1. Implement classification heuristics: Create a function that classifies incoming messages into one of the three tiers based on the proposed heuristics:
def classify_message(message):
    if len(message) < 20 and ("yes" in message or "do it" in message or "thanks" in message):
        return "fast"
    elif "think about" in message or "analyze" in message or "debug" in message:
        return "deep"
    else:
        return "standard"
  1. Integrate with the existing model selection logic: Modify the code that selects the model for each message to use the classified tier:
def select_model(message):
    tier = classify_message(message)
    if tier == "fast":
        return "claude-haiku-3.5"
    elif tier == "deep":
        return "claude-opus-4"
    else:
        return "claude-sonnet-4"
  1. Add user controls: Implement the proposed user controls, such as per-message override and floor setting:
def handle_user_input(message):
    if message.startswith("/deep"):
        return "claude-opus-4"
    # ...
  1. Track savings and provide transparency: Implement a cost dashboard and add a subtle indicator to show which tier handled each response.

Verification

To verify that the fix worked, test the following scenarios:

  • Simple messages are routed to the "fast" tier
  • Complex messages are routed to the "deep" tier
  • Messages that don't match any specific tier are routed to the "standard" tier
  • User controls (e.g., per-message override, floor setting) work as expected

Extra Tips

  • Monitor the performance of the classification heuristics and adjust them as needed to improve accuracy.
  • Consider implementing LLM-based classification as a future enhancement to improve accuracy.
  • Ensure that the cost dashboard and transparency features are accurate and easy to use.

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

openclaw - 💡(How to fix) Fix Feature Request: Automatic Model Switching (Smart Routing) [1 participants]