Query Router

v1.1.0

Unified query router combining content-type detection, complexity scoring, and prefix-based routing. Routes queries to the optimal model with safety features...

0· 112·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for walterwkchoy/query-router.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Query Router" (walterwkchoy/query-router) from ClawHub.
Skill page: https://clawhub.ai/walterwkchoy/query-router
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install query-router

ClawHub CLI

Package manager switcher

npx clawhub@latest install query-router
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (route queries to optimal models) match the code and SKILL.md: prefix/content-type/complexity routing, mapping to cloud/local models. The use of the 'openclaw' CLI and a localhost model tags endpoint is coherent for a router that needs current model state and available models.
Instruction Scope
Runtime instructions and the code operate within the claimed domain: classify input, decide model, optionally call 'openclaw' to check/verify status, and write local audit logs. The skill references only local files (.locks, .logs) and localhost HTTP; it does not exfiltrate to external servers or request unrelated system secrets.
Install Mechanism
No install spec is provided (instruction-only). The package includes Python scripts but does not download or extract remote artifacts. This is the lowest-risk install pattern for a script-based skill.
Credentials
The skill declares no required env vars or credentials and the code does not read secrets. It invokes a local CLI ('openclaw') and contacts http://localhost:11434 which are proportional to discovering models; no unrelated service tokens are requested.
Persistence & Privilege
always is false and the skill does not attempt to modify global skill config. It creates local lock and log files under scripts/.locks and scripts/.logs, which is expected for routing/audit behavior and does not indicate elevated privileges.
Assessment
This skill appears coherent for routing queries: it classifies queries, consults a local model endpoint (http://localhost:11434/api/tags) and the 'openclaw' CLI, and writes audit logs under scripts/.logs and lock files under scripts/.locks. Before installing, verify you trust the skill source (homepage unknown) and that running 'openclaw' and a local model registry on localhost is expected in your environment. Review the included Python files yourself or run the scripts in a safe/test workspace; note they log up to the first 100 characters of queries to a JSONL file, so avoid sending sensitive secrets through queries if you enable this skill.

Like a lobster shell, security has layers — review code before you run it.

latestvk9711hk23wvbn04aq8b1p5xdfh843xbk
112downloads
0stars
5versions
Updated 3w ago
v1.1.0
MIT-0

Query Router

Routes every query to its best-fit model using three routing strategies combined:

  1. Prefix routing — explicit user intent (@codex, @mini, etc.)
  2. Content-type detection — auto-detect vision/voice/tool/code/reasoning/qa
  3. Complexity scoring — simple/moderate/complex tier routing

Usage

Classify only

python3 skills/query-router/scripts/classify.py [--json] [--attachment .ext] <query>

Route (classify + switch model)

python3 skills/query-router/scripts/router.py [--json] [--dry-run] [--attachment .ext] <query>

Safety & Audit

python3 skills/query-router/scripts/router.py --check           # list available models
python3 skills/query-router/scripts/router.py --audit            # show recent routing log
python3 skills/query-router/scripts/router.py --no-lock          # disable lock protection
python3 skills/query-router/scripts/router.py --dry-run --no-verify  # preview without verify

Library usage

from router import route_query

result = route_query(
    query="@codex write a complex python script",
    has_attachment=False,
    attachment_ext="",
    dry_run=True,       # True = preview, False = actually switch
    enable_lock=True,   # prevent concurrent routing
    enable_verify=True, # readback verify after switch
    enable_rollback=True,  # revert on failure
)
print(result["action"])        # route | recommend | skip | blocked
print(result["to_model"])      # recommended model name
print(result["classification"]) # full classification details

Routing Priority

PrioritySignalExampleBehavior
1Prefix@codex write a scriptForce switch to @codex model
2Content-type (≥60%% conf)describe this imageAuto-switch to vision model
3Complexity (<60%% conf)analyze Q3 dataRoute by complexity tier
4Skip (<30%% conf)hi how are youKeep current model

Prefix Routing

PrefixModelAliases
@codexopenai-codex/gpt-5.3-codex@c
@miniminimax-m2.7:cloudCloud primary
@clqwen3-coder-next:cloudCloud code
@qminimax-m2.7:cloudCloud fast Q&A
@llavaqwen3.5:cloudCloud vision
@whisperwhisper

Content Types

TypeDetected ByBest Model
visionImage attachment or "describe/identify"qwen3.5:cloud
voiceAudio file or "transcribe/speech-to-text"whisper
toolrun, fetch, send, check, syncminimax-m2.7:cloud
codescript, function, import, debugqwen3-coder-next:cloud
reasoninganalyze, compare, plan, thinkminimax-m2.7:cloud
qawhat is, how does, defineminimax-m2.7:cloud

Complexity Tiers

TierPatternModel
simplegreetings, one-liners, short questionsminimax-m2.7:cloud
moderateemails, analysis, search, translateminimax-m2.7:cloud
complexmulti-file code, deep research, architectminimax-m2.7:cloud

Safety Features

  • Lock protection — prevents concurrent routing ops (fcntl)
  • Verify-after-switch — confirms model actually changed
  • Rollback — reverts to previous model on failure
  • Audit log — JSONL log at scripts/.logs/router.log.jsonl

Merged Approaches

SourceTechnique
openclaw-model-router-skillPrefix syntax @codex/@mini, lock + verify + rollback
task-complexity-routerComplexity tier scoring (simple/moderate/complex)
query-router (original)Content-type detection (vision/voice/tool/code/qa)

All three combined into one unified router with confidence-based priority.

Comments

Loading comments...