A drop-in skill for OpenClaw that allows the primary AI model (Kimi K2.5) to escalate complex tasks to a more powerful model — without switching the default model or disrupting the existing agent setup.
When the primary model determines a task exceeds its capabilities, it calls the escalation tool, which routes the task to the best available model, tracks token spend per session, and automatically falls back to the next model in the chain if the preferred one is over budget or unavailable.
- Kimi K2.5 identifies a task as too complex and calls
escalate_to_powerful_model - It selects the best target model and rates the task complexity (
low/medium/high) - The handler checks whether the target model has enough token budget remaining for the session
- If budget is sufficient, the task is sent to that model and the result is returned to Kimi
- If the model is over budget or fails, the handler automatically tries the next model in the fallback chain
- Token usage and escalation count are recorded in the session JSONL file and persist across restarts
| Priority | Model | Best for |
|---|---|---|
| 1 | claude-opus-4-6 |
Deep reasoning, complex debugging, multi-step analysis |
| 2 | gemini-2.0-pro |
Long context, document analysis, multimodal |
| 3 | gpt-4o |
Structured output, JSON schema, precise code generation |
openclaw-escalation/
├── tools/
│ ├── escalateToPowerfulModel.js # Main handler
│ └── escalateToPowerfulModel.tool.json # Tool definition for OpenClaw config
├── dispatch.js # Wiring example for tool dispatch
├── system-prompt-addition.txt # Add this to Kimi's system prompt
├── AgentInstallInstructions.txt # Step-by-step install guide for agents
├── .env.example # Environment variable template
├── package.json
└── CHANGELOG.md
- Copy
tools/escalateToPowerfulModel.jsinto your OpenClaw tools directory - Add the contents of
tools/escalateToPowerfulModel.tool.jsonto your tools array - Merge
dispatch.jsinto your existing tool dispatch logic - Copy
.env.exampleto.envand fill in your API keys - Append
system-prompt-addition.txtto Kimi's system prompt - Run
npm install
See AgentInstallInstructions.txt for detailed step-by-step instructions written for an AI agent to follow.
Edit MODEL_TOKEN_BUDGETS in tools/escalateToPowerfulModel.js to match your API limits:
const MODEL_TOKEN_BUDGETS = {
"claude-opus-4-6": 50000, // output tokens per session
"gemini-2.0-pro": 80000,
"gpt-4o": 40000,
};Default is 3 escalations per session. Change ESCALATION_LIMIT in the handler to adjust.
Remove its key from .env and its entry from the enum in escalateToPowerfulModel.tool.json.
Escalations are recorded as escalation_used events directly in OpenClaw's session JSONL files at:
~/.openclaw/agents/main/sessions/<session-id>.jsonl
Token counts survive process restarts. To audit usage:
# All escalations across all sessions
grep -r "escalation_used" ~/.openclaw/agents/main/sessions/
# Token spend for a specific session
grep "escalation_used" ~/.openclaw/agents/main/sessions/<session-id>.jsonl| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
If using Claude | From console.anthropic.com |
GEMINI_API_KEY |
If using Gemini | From aistudio.google.com |
OPENAI_API_KEY |
If using GPT-4o | From platform.openai.com |
MIT