Skip to content

Instantly share code, notes, and snippets.

@krllagent
Last active April 24, 2026 19:18
Show Gist options
  • Select an option

  • Save krllagent/a6e0cf558e9ff7b08480b8dcccd8522a to your computer and use it in GitHub Desktop.

Select an option

Save krllagent/a6e0cf558e9ff7b08480b8dcccd8522a to your computer and use it in GitHub Desktop.
The Advisor Pattern for OpenClaw — cheap agent model consults Claude Code for non-trivial decisions

The Advisor Pattern for OpenClaw

A cheap model runs your agent 24/7. Claude Code (on your subscription) whispers in its ear when things get tricky.

The problem: agents are expensive

OpenClaw agents consume a LOT of tokens — tool calls, retries, long conversations. Running on a mid-tier model through API easily costs hundreds of dollars per month. Opus? Forget it.

People used to work around this by routing OpenClaw through their Claude Pro/Max subscription instead of API keys — the subscription subsidized far more usage than raw API credits. But Anthropic recently shut that down.

The workaround: run your agent on a cheap model ($0.10-0.50/M tokens — MiniMax, Kimi, Haiku, GLM, etc.) and use Claude Code as the advisor. Claude Code runs on your existing Claude subscription. Your agent handles 90% of tasks alone. For the remaining 10% — the non-trivial ones — it consults Claude Code, which can use the smartest model you have access to (even Opus) within your subscription quota.

You get frontier-level reasoning on a budget-model budget.

This is inspired by The Advisor Strategy from Anthropic: Sonnet paired with an Opus advisor scored higher than Sonnet alone on SWE-bench Multilingual while costing 12% less per task. Same idea, but instead of paying for Opus API calls, you're using your subscription.

How it works

Most tasks an agent handles are straightforward: send a message, set a reminder, look something up. A cheap model handles these fine. But when a task requires planning — multiple steps, unfamiliar tools, risk of breaking something — the cheap model guesses and fails.

The fix: before executing anything non-trivial, the agent calls Claude Code and asks "how should I do this?" The advisor returns a plan (typically 400-700 tokens), the agent follows it. The advisor never executes — only thinks.

Setup

Add this to your TOOLS.md:

## Advisor

Before executing a non-trivial task, consult the advisor for a plan.

**When to use:**
- Task has more than one obvious step
- You're unsure about the right approach
- Task could break something if done wrong

**When NOT to use:**
- Simple single-action tasks (send message, set reminder, add to list)
- Pure coding tasks — send those to the coding agent to DO the work, not advise
- You already know how to execute

**Call:**

bash pty:true workdir:<PROJECT_OR_HOME_DIR> command:"claude -p 'You are an advisor. I am an AI agent that received a task. I need ADVICE — do NOT do the task, only give me a plan.

TASK: <what the user asked>
CONTEXT: <what you know — files, prior attempts, what works/doesn't>
MY TOOLS: <your available tools>

Give a step-by-step plan: which tools, what order, what parameters. If any step needs code — say to delegate to a coding agent. Warn about pitfalls.'"

**Rules:**
- One call, then wait (1-5 min, advisor only thinks)
- Execute the plan yourself; code steps go to coding agent as usual
- If plan fails twice — ask the user, don't keep guessing

That's it. No packages to install, no config files. Your agent reads the instruction, calls claude -p when stuck, gets a plan, follows it.

Why this works

  • Cost: Your main agent runs on a ~$0.15/M model. The advisor runs on your Claude subscription — no extra API spend. The advisor generates ~500 tokens per consultation, so even heavy use barely dents your quota.
  • Quality: The cheap model stops guessing multi-step approaches. It asks someone smarter, then executes confidently.
  • Safety: "Think before you act" prevents the agent from trying random things that break your system.
  • Separation: The advisor sees your project files (via workdir) but never modifies them. It only returns text.

Example

User says: "Post about our project on Reddit"

Without advisor — agent opens headless browser, Reddit blocks it, agent tries curl, gets 403, tries again, wastes 10 minutes and 50K tokens.

With advisor — agent asks Claude Code: "How do I post on Reddit? I have a headless browser (blocked by Reddit) and a desktop Chromium on display :1 with xdotool." Advisor replies: "Use the desktop browser. Steps: 1) open reddit.com/r/... via xdotool 2) click Create Post 3) type title 4) submit." Agent follows the plan, done in 2 minutes.

Adapting for your setup

The example uses claude -p (Claude Code CLI on a Claude subscription). You can substitute with any smarter model:

  • Claude Code (subscription): claude -p 'prompt' — the sweet spot, uses your existing quota
  • Codex: codex exec 'prompt'
  • API call: curl to any model endpoint (if you prefer to pay per token)
  • OpenClaw subprocess: sessions_spawn with a smarter model profile

The pattern is model-agnostic. The only requirement: the advisor must be meaningfully smarter than your executor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment