β Over-delegation
Spawning a sub-agent to read a file wastes more time than it saves. Apply the 30-second rule ruthlessly.
One agent can do a lot. But one agent doing everything β writing code, researching competitors, drafting emails, deploying servers β is a disaster waiting to happen. Context fills up, mistakes compound, and the agent loses the thread.
The CEO Pattern solves this. Your main agent stops doing work and starts coordinating work. Specialists execute. The CEO verifies.
A CEO doesnβt write the companyβs code. They define what needs to be built, assign it to the right person, review the result, and decide whether itβs good enough. Your orchestrator agent should operate the same way.
CEO Agent (Opus)βββ Defines the task with clear scopeβββ Picks the right specialist modelβββ Spawns the sub-agent with explicit instructionsβββ Waits for completionβββ Verifies the output (runs tests, checks links, validates format)βββ Iterates if broken (sends feedback to same agent)βββ Reports success to user ONLY when verifiedThe user never sees broken work. The CEO is the quality gate. This is the whole point.
The hardest part is knowing when to delegate. Delegate too aggressively and you waste time on spawn overhead. Do too much yourself and your CEO drowns in details.
ββ Is this < 30 seconds?β ββ YES β Do it yourself (file read, git status, quick lookup)β ββ NO ββββ Is this > 5 minutes OR > 3 steps?β ββ YES β Delegate to specialistβ ββ NO ββββ Can parts run in parallel?β ββ YES β Spawn multiple specialists simultaneouslyβ ββ NO β Single specialistβββ Needs domain expertise? ββ Coding β haiku coding agent ββ Research β haiku researcher agent ββ Writing β sonnet writer agent ββ Analysis β sonnet or opus analystMatch the model to the task. This directly impacts cost and quality:
| Task Type | Model | Timeout | Why |
|---|---|---|---|
| Code builds / test suites | Haiku | 15 min | Fast iteration, deterministic tasks |
| Web research / scraping | Haiku | 5 min | Pattern matching, data extraction |
| Content drafting | Sonnet | 3 min | Needs voice, nuance, flow |
| Strategic analysis | Opus | 10 min | Complex reasoning required |
| Data transformation | Haiku | 5 min | Mechanical, well-scoped |
| Deployment pipelines | Haiku | 10 min | Scripted, clear success criteria |
| Legal / compliance review | Opus | 5 min | High-stakes, nuanced judgment |
Running your CEO on Opus is correct β itβs making strategic decisions. Running everything on Opus is a mistake β youβll burn 10Γ the tokens for tasks that donβt need that reasoning capacity.
In OpenClaw, the CEO spawns specialists using sessions_spawn:
// CEO agent spawning a coding sub-agentconst result = await sessions_spawn({ agentId: "coding", // Specialist agent ID from openclaw.json task: ` Build a REST API endpoint for user authentication.
Requirements: - POST /api/auth/login with email + password - Returns JWT token on success - Rate limiting: 5 attempts per IP per minute - Unit tests for happy path + 3 edge cases
Working directory: ~/projects/myapp/ Test command: npm test
Report back with: files modified, test results, any blockers. `, model: "anthropic/claude-haiku-4", timeout: "15m", workdir: "~/projects/myapp/"});Key fields:
agentId: The specialistβs agent ID (must exist in openclaw.json)task: The complete, self-contained task descriptionmodel: Override model for this specific spawn (optional)timeout: Hard limit β agent is killed if it exceeds thisworkdir: Working directory for file operationsThis is where most orchestration systems fail. They delegate, receive output, and forward it to the user without checking. Thatβs a relay, not orchestration.
Real orchestration includes a verification step:
CEO spawns coding agent βAgent returns: "Done, code is at src/auth.ts" βCEO runs verification: cd ~/projects/myapp && npm test βTests pass? β CEO reports success to userTests fail? β CEO sends feedback to SAME agent: "Tests failing on rate limiter: Error: Cannot read property 'count' of undefined Fix the rate limiter implementation." βAgent returns fix βCEO runs tests again... βRepeat until passing or timeoutIn practice, this looks like a loop:
async function orchestrateCodingTask(task: string, maxRetries = 3) { let attempts = 0;
while (attempts < maxRetries) { // Spawn or steer the coding agent const result = await sessions_spawn({ agentId: "coding", task: attempts === 0 ? task : `Fix the failing tests: ${lastError}`, timeout: "15m" });
// CEO verifies β runs actual tests const testResult = await exec("npm test 2>&1");
if (testResult.exitCode === 0) { return { success: true, output: result }; }
lastError = testResult.stdout; attempts++; }
return { success: false, error: `Failed after ${maxRetries} attempts` };}The real power multiplier: when tasks are independent, run them simultaneously.
CEO receives: "Analyze competitor pricing and build a pricing comparison page"
Sequential (slow): Research competitor pricing β 12 minutes Build comparison page β 15 minutes Total: 27 minutes
Parallel (fast): ββ Research competitor pricing β 12 minutes ββ ββ Build comparison page scaffold β 15 minutes ββ CEO integrates results: β 2 minutes Total: 17 minutes (37% faster)Implementation:
// Spawn both agents simultaneouslyconst [researchResult, buildResult] = await Promise.all([ sessions_spawn({ agentId: "researcher", task: "Find pricing for: Competitor A, B, C. Format as JSON with {name, tiers, price_per_seat}.", timeout: "5m" }), sessions_spawn({ agentId: "coding", task: "Build pricing comparison page scaffold at src/pages/pricing-comparison.tsx. Leave competitor data as placeholder JSON.", timeout: "15m" })]);
// CEO integratesawait sessions_spawn({ agentId: "coding", task: `Integrate this competitor data into the pricing page:${researchResult.data}
The page scaffold is at src/pages/pricing-comparison.tsx`, timeout: "5m"});Hereβs a complete example β a CEO agent handling a βbuild me a landing page for my productβ request:
CEO analyzes the request
Breaks it into parallel tracks: research (what do top landing pages include?) + build (scaffold from template).
CEO spawns parallel agents
Researcher: "Find 3 best-in-class SaaS landing pages. Extract: hero copy patterns,social proof placement, CTA placement. Return as structured JSON."
Coder: "Build landing page at src/pages/landing.tsx using our design system.Include: hero, features, social proof, pricing, CTA. Use placeholder content."CEO waits for both
Researcher returns in ~3 minutes. Coder returns in ~10 minutes.
CEO integrates
Writer: "Write hero copy for [product]. Use these patterns from top landing pages:[researcher output]. Target audience: [audience]. Voice: [brand voice]."CEO verifies
npm run build # Does it compile?npm run test # Do tests pass?# Open localhost:3000 β does it look right?CEO iterates on failures
Build error? Sends error to coding agent. Copy feels off? Sends feedback to writer.
CEO delivers
Only after the build passes and the page looks correct does the CEO report back to the user.
β Over-delegation
Spawning a sub-agent to read a file wastes more time than it saves. Apply the 30-second rule ruthlessly.
β No timeout discipline
A stuck agent burns tokens indefinitely. Set explicit timeouts on every spawn. Default: 15 min coding, 5 min research.
β Context dumping
Passing 10,000 tokens of memory to a coding agent that only needs 200 tokens of task context. Give specialists what they need, nothing more.
β Skipping verification
βThe sub-agent said it workedβ is not verification. Run the tests. Check the output. You are the quality gate.
β Too many concurrent agents
Each active agent consumes API resources. Cap at 5 concurrent children per session. Queue the rest.
β New session on retry
Starting a fresh sub-agent for every retry loses context. Steer the existing agent β it knows what it already tried.
Register your specialists in openclaw.json:
{ "agents": { "main": { "workspace": "~/clawd", "model": "anthropic/claude-opus-4", "description": "CEO orchestrator" }, "coding": { "workspace": "~/clawd/specialists/coding", "model": "anthropic/claude-haiku-4", "description": "Builds and tests software", "soul": "You are a coding specialist. You write clean, tested code. Always run tests before reporting success. Report back: files changed, test output, any blockers." }, "researcher": { "workspace": "~/clawd/specialists/research", "model": "anthropic/claude-haiku-4", "description": "Web research and data extraction", "soul": "You are a research specialist. You find accurate, recent information. Always cite sources. Return structured JSON when asked. Be skeptical of unverified claims." }, "writer": { "workspace": "~/clawd/specialists/writing", "model": "anthropic/claude-sonnet-4", "description": "Content and communications drafting", "soul": "You are a writing specialist. You write with a clear, human voice. No corporate jargon. No filler. Match the tone you're given. Show, don't tell." } }}A CEO agent that can:
The result: You give the CEO a goal, and you get back a finished product β not a βhereβs what I tried, good luck.β
About the author: JD Davenport builds AI agent systems at OpenClaw. Follow on LinkedIn for updates on building AI agents for business.