Tutorial

How to Run Multiple AI Agents in OpenClaw (Subagent Architecture)

Learn how OpenClaw's subagent system works, how to spawn parallel agents for heavy tasks, and how to avoid the RAM and zombie process traps that crash your server.

March 18, 2026·9 min read

OpenClaw runs multiple AI agents in parallel. One agent writes content while another checks SEO rankings while a third monitors your server. This is how you scale from a single chatbot to a full AI team.

This guide covers the subagent architecture, how to spawn agents correctly, and the two failure modes that bring everything down.

Don't want to manage this yourself? MrDelegate runs a pre-configured multi-agent setup on managed OpenClaw infrastructure. See managed hosting →

How OpenClaw Subagents Work

When your main agent session spawns a subagent, OpenClaw:

  1. Creates a new isolated session with its own context window
  2. Passes the task prompt and any relevant files
  3. Runs the session independently — parallel to your main session
  4. Auto-announces the result back to the spawning session when complete

The main session doesn't block while waiting. It can continue other work. Results arrive via push notification, not polling.

This enables real parallelism: spawn 3 agents to write 3 blog posts simultaneously. Total time = time for 1 post, not 3.

When to Spawn a Subagent

The rule is simple: if a task takes more than 5 minutes, spawn an agent. Don't do it yourself.

Tasks that benefit from subagents:

  • Writing articles (each article = 1 agent)
  • SEO audits across multiple domains
  • Code builds that require exploration + editing
  • Data processing jobs (parse 500 rows of data)
  • Multi-step research tasks

Tasks to do yourself (in main session):

  • One-liner file edits
  • Simple API calls
  • Reading files and checking status
  • Anything under 2 minutes

The main session is the orchestrator. It delegates. It monitors. It unblocks. It doesn't grind through 500 rows of data itself.

The RAM Problem: Why Agents Crash Servers

Each OpenClaw agent session uses approximately 200-400MB RAM. Spawn 6 agents on a 4GB VPS and you've consumed 2.4GB just in agent processes — before your web server, database, and OS.

The failure mode: agents finish their work but the process doesn't fully terminate. These zombie processes accumulate over hours, eating RAM until the server OOM-kills your web server.

Check for zombies before any major agent sprint:

ps aux | grep claude-agent-acp | wc -l

If the count exceeds 10, clean up first:

pkill -f "claude-agent-acp"

This is safe — agents that are actually running will be terminated, but zombie processes from completed sessions are gone. The value they produced (files, commits) is already saved.

Hard limits that prevent crashes:

  • RAM > 80% — no new agents
  • More than 5 active agents — no new agents
  • Before any sprint — run free -h and check available RAM
Important: A crashed server means a downed site. Check RAM before spawning. A 2-second check saves a 20-minute recovery.

Agent Architecture: Two Types

OpenClaw agents fall into two categories. Mixing them causes problems.

Builder Agents

Builder agents write code, create files, commit to git. They have write access to your workspace. Use them for:

  • Creating new features
  • Writing articles
  • Building integrations
  • Refactoring code

Builder agents should never touch infrastructure: env files, systemd configs, nginx configs, SSL certs. Those changes live in your infra layer, not your code layer.

QA / Audit Agents

QA agents are read-only. They check, verify, and report. They never modify anything.

Every QA agent prompt must start with: "READ ONLY — do not modify any files, env, configs, or code."

If they find a bug, they report it. The main session fixes it. A QA agent that also fixes bugs is an agent with unclear boundaries — it will eventually break something by trying to be helpful.

Spawning Agents: The Right Way

A good agent spawn includes:

  1. Clear objective — what does done look like? Be specific.
  2. Time budget — "you have 10 minutes" forces output over planning
  3. File output requirement — "write all files before optimizing"
  4. Explicit commit instruction — agents that don't commit produce work that's lost on restart
  5. Success criteria — how will I verify it worked?

Example of a well-formed agent task:

Task: Write a 1500-word blog post about OpenClaw vs n8n.

Requirements:
- Target keyword: "openclaw vs n8n"
- Include concrete comparison table (speed, cost, complexity)
- 3 CTAs linking to /blog/
- No filler. Short sentences. Active voice.
- Save to: /root/mrdelegate/astro/seo/articles/openclaw-vs-n8n-2026.md

Time budget: 8 minutes.
After writing: git add -A && git commit -m "article: openclaw vs n8n 2026"

The commit instruction is non-negotiable. An agent that writes files without committing produces work that disappears on the next server restart.

Monitoring Active Agents

Push-based completion means you don't poll for status. Results arrive automatically. But you should check on agents that have been running over 15 minutes with no output.

Signs an agent is stuck:

  • Running 20+ minutes on a writing task with no files created
  • Timeout with message "let me write all X now" (means it wrote nothing)
  • Repeated planning/research loops without shipping

When an agent is stuck: kill it and redo the task yourself with direct commands. An agent stuck in planning loops will not unstick itself — it will burn context and time.

Agent Lanes: Preventing Scope Creep

Multi-agent setups fail when agents do each other's jobs. Define clear lanes and enforce them in prompts.

A working division for a content operation:

  • Mr. SEO — keyword research, technical audits, rank tracking. Does NOT write articles.
  • Mr. Copy — writes articles. Does NOT do SEO research.
  • Mr. Web — code and platform features. Does NOT write content.
  • Mr. QA — audits only, read-only. Does NOT fix things.

Every agent spawn should address one lane. Cross-lane spawns create coordination problems and usually produce work that conflicts.

MrDelegate runs a 10-agent setup by default. Managed hosting includes pre-configured lanes, RAM monitoring, and zombie cleanup. See the full setup →

Parallel vs Sequential Agents

Parallel agents run simultaneously — use when tasks are independent.

Sequential agents run one after another — use when task 2 needs output from task 1.

Example of parallel (correct):

// These don't depend on each other — run simultaneously
spawn: write article A
spawn: write article B
spawn: write article C

Example of sequential (correct):

// Step 2 needs step 1's output
spawn: SEO research for "openclaw pricing" keywords
// Wait for result
spawn: Write article using those keywords (pass keyword list)

Spawning step 2 before step 1 finishes wastes the subagent — it has no data to work with.

Related Reading