npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shawnmandel/openclaw-tier-router

v2.2.0

Published

Rules-based complexity routing across model tiers for OpenClaw

Downloads

34

Readme

Tier Router — OpenClaw Plugin

Rules-based complexity routing across model tiers. Routes simple tasks to cheap/fast local models and complex tasks to capable cloud models, with deterministic classification — no LLM needed for routing decisions.

Why

OpenClaw's native fallback system is failure-recovery only — it tries the next model when the current one fails. This plugin adds pre-routing: every inbound message is classified by complexity and routed to the appropriate model tier before inference begins.

How It Works

The plugin hooks into before_model_resolve — the first hook in OpenClaw's pipeline. It extracts the user's message text, classifies it using deterministic regex patterns, and returns modelOverride + providerOverride to route to the correct tier.

No tokens are consumed for routing. Classification is instant (~1ms).

Routing Rules

Priority order (first match wins):

| Rule | Routes To | Examples | |---|---|---| | Manual override keywords | Specified tier | "use opus", "use groq", "use local" | | File paths detected | Tier 3 | /home/user/config.json, ~/project/ | | Skill patterns | Tier 3 | "generate image", "run command", "web search" | | Complex patterns | Tier 2 (short) or Tier 3 (50+ words) | "debug", "architect", "plan", "reason" | | Debug patterns | Tier 2 | "fix this broken", "not working", "crashed" | | Moderate patterns | Tier 1 | "code", "script", "install", "git" | | Long unmatched (80+ words) | Tier 2 | Any long message without keyword matches | | System messages | Tier 1 | Session startup, heartbeats | | Everything else | Tier 1 | Default — cheapest model |

Manual Overrides

Include these phrases anywhere in your message to force a specific tier:

  • Tier 1: "use local", "use ollama", "use qwen", "use tier1"
  • Tier 2: "use groq", "use tier2"
  • Tier 3: "use opus", "use claude", "use anthropic", "use tier3"

Installation

Copy the tier-router/ directory into your OpenClaw extensions folder:

~/.openclaw/extensions/tier-router/
├── openclaw.plugin.json
├── index.ts
└── README.md

Configuration

Add to your openclaw.json:

{
  "plugins": {
    "allow": ["tier-router"],
    "entries": {
      "tier-router": {
        "enabled": true,
        "config": {
          "tier1": { "model": "your-local-model", "provider": "ollama" },
          "tier2": { "model": "your-mid-model", "provider": "groq" },
          "tier3": { "model": "your-best-model", "provider": "anthropic" },
          "complexWordThreshold": 50,
          "longPromptThreshold": 80
        }
      }
    }
  }
}

Config Fields

| Field | Type | Default | Description | |---|---|---|---| | tier1.model | string | required | Model ID for simple/moderate tasks | | tier1.provider | string | required | Provider name for Tier 1 | | tier2.model | string | required | Model ID for complex tasks | | tier2.provider | string | required | Provider name for Tier 2 | | tier3.model | string | required | Model ID for skills/tool-calling/deep reasoning | | tier3.provider | string | required | Provider name for Tier 3 | | complexWordThreshold | number | 50 | Word count above which complex matches escalate to Tier 3 | | longPromptThreshold | number | 80 | Word count above which unmatched messages route to Tier 2 |

If no config is provided, the plugin falls back to built-in defaults. For production use, always provide explicit config.

Logs

The plugin logs every routing decision to stdout with the [TIER-ROUTER] prefix:

[TIER-ROUTER] === ROUTING DECISION ===
[TIER-ROUTER] user text: "Debug this config issue"
[TIER-ROUTER] classification: TIER2-COMPLEX
[TIER-ROUTER] model: groq/llama-3.3-70b-versatile
[TIER-ROUTER] reason: complex keyword: "Debug"

Filter logs: docker logs <container> --since 5m 2>&1 | grep "TIER-ROUTER"

Known Limitations

  • Groq/Llama models cannot do tool-calling in OpenClaw (bug #17598). Skill patterns route to Tier 3 for this reason.
  • extractUserText relies on OpenClaw's prompt envelope format. If the format changes, classification may degrade.
  • File path detection may false-positive on casual path mentions. URLs are excluded.
  • /new session label shows the config default model, not the router override. This is cosmetic — actual inference uses the routed tier.

Requirements

  • OpenClaw v2026.3.x or later
  • configSchema support in plugin manifests

License

MIT