← 返回 Skills 市场
joelnishanth

Adaptive Routing

作者 joelnishanth · GitHub ↗ · v1.0.0
cross-platform ✓ 安全检测通过
429
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install adaptive-routing
功能描述
Routes LLM requests to a local model first (Ollama, LM Studio, llamafile), validates the response quality, and escalates to cloud only when the local result...
使用说明 (SKILL.md)

Adaptive Routing

Route requests to a local LLM first. Validate the response quality. Escalate to cloud only when the local result fails the quality check. Track every outcome in a persistent dashboard.

Quick Start

1. Check if a local LLM is running

python3 skills/adaptive-routing/scripts/check_local.py

Returns JSON: { "any_available": true, "best": { "provider": "ollama", "models": [...] } }

2. Route a request

python3 skills/adaptive-routing/scripts/route_request.py \
  --prompt "Summarize this meeting transcript" \
  --tokens 800 \
  --local-available \
  --local-provider ollama

Returns: { "decision": "local", "reason": "...", "complexity_score": -1, "complexity_threshold": 3 }

3. Execute with the chosen provider

Send the request to your local provider (Ollama, LM Studio, or llamafile).
See references/local-providers.md for curl examples.

4. Validate the response

python3 skills/adaptive-routing/scripts/validate_result.py \
  --response "The meeting covered three topics..." \
  --exit-code 0

Returns: { "passed": true, "score": 1.0, "reason": "ok", "should_escalate": false }

If should_escalate: true, re-run step 3 with your cloud provider instead.

5. Log the outcome

# Local success (no escalation needed)
python3 skills/adaptive-routing/scripts/track_savings.py log \
  --kind local_success --tokens 800 --model gpt-4o

# Escalated (local failed validation, used cloud)
python3 skills/adaptive-routing/scripts/track_savings.py log \
  --kind escalated --tokens 800 --model gpt-4o

6. Show the dashboard

python3 skills/adaptive-routing/scripts/dashboard.py

Full Routing Workflow

┌──────────────────────────────────────────────────────────┐
│  1. check_local.py  →  is a local provider running?      │
│                                                           │
│  2. route_request.py  →  local or cloud?                  │
│     · sensitivity check  (private data → local)          │
│     · complexity score   (high score → cloud)            │
│     · availability gate  (no local → cloud)              │
│                                                           │
│  3. Execute with local provider                          │
│                                                           │
│  4. validate_result.py  →  did the response pass?        │
│     · passed=true   → use result   (kind=local_success)  │
│     · passed=false  → re-run cloud (kind=escalated)      │
│                                                           │
│  5. track_savings.py log  →  record the outcome          │
│                                                           │
│  6. dashboard.py  →  show cumulative savings             │
└──────────────────────────────────────────────────────────┘

Routing Rules (Summary)

Condition Route
No local provider available ☁️ Cloud
Prompt contains sensitive data (password, secret, api key, ssn, etc.) 🏠 Local
Complexity score ≥ threshold (default 3) ☁️ Cloud
Complexity score \x3C threshold 🏠 Local

After routing locally, validate_result.py applies a second gate:

Signal Escalate?
Empty response Yes
Process exit code != 0 Yes
Timed out Yes
Tool error Yes
Clean response, score ≥ 0.75 No

For full scoring details, see references/routing-logic.md.


Configuration

Create ~/.openclaw/adaptive-routing/config.json to tune thresholds:

{
  "complexity_threshold": 3,
  "token_high_watermark": 4000,
  "token_low_watermark": 500,
  "redact_output": true
}

Pass --config /path/to/config.json to route_request.py to use a custom path.


Executing with a Local Provider

Once route_request.py returns "decision": "local", send the request:

Ollama

curl http://localhost:11434/api/generate \
  -d '{"model": "llama3.2", "prompt": "YOUR_PROMPT", "stream": false}'

LM Studio / llamafile (OpenAI-compatible)

curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "local-model", "messages": [{"role": "user", "content": "YOUR_PROMPT"}]}'

Dashboard

The dashboard reads from ~/.openclaw/adaptive-routing/savings.json (auto-created).

┌───────────────────────────────────────────────┐
│      🔀  Adaptive Routing  ·  Dashboard       │
├───────────────────────────────────────────────┤
│  Local LLM:  ✅  ollama (llama3.2...)         │
├───────────────────────────────────────────────┤
│  Total requests:                           42  │
│  Local (passed):               31  (73.8%)    │
│  Escalated to cloud:                        4  │
│  Cloud (direct):                            7  │
│  Escalation rate:                       11.4%  │
├───────────────────────────────────────────────┤
│  Tokens (local):                       84,200  │
│  Tokens (cloud):                        9,600  │
│  Cost saved (USD):                     $0.4210 │
└───────────────────────────────────────────────┘

Reset savings data:

python3 skills/adaptive-routing/scripts/track_savings.py reset

Additional References

安全使用建议
This skill appears coherent and implements what it claims. Before installing, consider: (1) it will create ~/.openclaw/adaptive-routing/ (config and savings files) — review or remove these if you don't want local persistence; (2) it probes localhost ports to detect local LLM servers — if you run untrusted services locally that could be fingerprinted, be aware of that network activity; (3) the docs reference provider install commands (including curl | sh for Ollama) — running remote install scripts can be risky; prefer official release packages from trusted sources; (4) the redaction logic reduces risk of logging API keys, but review the scripts if you plan to feed highly sensitive prompts; (5) no cloud credentials are required by the skill itself — escalation to cloud is left to your environment and tooling. If you want extra assurance, inspect the bundled Python scripts (they are small and readable) or run them in a restricted/test account first.
功能分析
Type: OpenClaw Skill Name: adaptive-routing Version: 1.0.0 The OpenClaw skill bundle 'adaptive-routing' is classified as benign. All Python scripts (`check_local.py`, `dashboard.py`, `route_request.py`, `track_savings.py`, `validate_result.py`) perform actions strictly aligned with the stated purpose of routing LLM requests locally, validating responses, and tracking savings. Network calls are exclusively to `localhost` (e.g., `http://localhost:11434`) to detect local LLM providers, posing no external data exfiltration risk. File system interactions are limited to reading/writing configuration and data files within `~/.openclaw/adaptive-routing/`, which is standard for skill persistence. The `SKILL.md` and `references/*.md` files contain clear instructions and examples for user setup and interaction, including `curl` commands to `localhost` and `ollama install` commands, but these are not designed for prompt injection against the AI agent or for the agent to execute directly as part of its runtime. There is no evidence of malicious intent, data exfiltration, unauthorized remote control, or persistence mechanisms.
能力评估
Purpose & Capability
Name/description align with included scripts and docs. The skill only needs python3, checks local LLM HTTP endpoints (Ollama/LM Studio/llamafile), decides routing, validates responses, and records outcomes. No unrelated credentials, binaries, or external services are requested by the skill itself.
Instruction Scope
SKILL.md and scripts remain within the declared scope: they query localhost endpoints, run local validation heuristics, and persist usage data under ~/.openclaw/adaptive-routing/. The skill does not send user prompts to third-party endpoints itself. Note: it creates/configures files in the user's home directory and runs subprocesses/HTTP requests to localhost (expected for detecting local LLMs).
Install Mechanism
This is an instruction-only skill with bundled Python scripts and no install spec. Nothing is downloaded or extracted by the skill itself. The references mention upstream provider install commands (e.g., curl | sh for Ollama) — those are provider instructions, not the skill's installer.
Credentials
No environment variables or credentials are required by the skill. The scripts include secret-detection/redaction patterns to avoid logging API keys and bearer tokens. The skill stores only metadata (tokens, model, outcome) in savings.json — it does not persist prompt contents or credentials.
Persistence & Privilege
The skill persists data under ~/.openclaw/adaptive-routing/ (config.json, savings.json) and does not request always:true or modify system-wide/other-skills configuration. It runs only when invoked and does not demand elevated privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install adaptive-routing
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /adaptive-routing 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release — pre-flight routing, post-outcome validation, escalation to cloud, v2 savings ledger with local_success/escalated/cloud/bypassed tracking
元数据
Slug adaptive-routing
版本 1.0.0
许可证
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Adaptive Routing 是什么?

Routes LLM requests to a local model first (Ollama, LM Studio, llamafile), validates the response quality, and escalates to cloud only when the local result... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 429 次。

如何安装 Adaptive Routing?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install adaptive-routing」即可一键安装,无需额外配置。

Adaptive Routing 是免费的吗?

是的,Adaptive Routing 完全免费(开源免费),可自由下载、安装和使用。

Adaptive Routing 支持哪些平台?

Adaptive Routing 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Adaptive Routing?

由 joelnishanth(@joelnishanth)开发并维护,当前版本 v1.0.0。

💬 留言讨论