← Back to Skills Marketplace
joelnishanth

Adaptive Routing

by joelnishanth · GitHub ↗ · v1.0.0
cross-platform ✓ Security Clean
429
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install adaptive-routing
Description
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...
README (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

Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install adaptive-routing
  3. After installation, invoke the skill by name or use /adaptive-routing
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release — pre-flight routing, post-outcome validation, escalation to cloud, v2 savings ledger with local_success/escalated/cloud/bypassed tracking
Metadata
Slug adaptive-routing
Version 1.0.0
License
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 429 downloads so far.

How do I install Adaptive Routing?

Run "/install adaptive-routing" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Adaptive Routing free?

Yes, Adaptive Routing is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Adaptive Routing support?

Adaptive Routing is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Adaptive Routing?

It is built and maintained by joelnishanth (@joelnishanth); the current version is v1.0.0.

💬 Comments