What Are Sub-Agents?
Sub-agents are isolated AI sessions spawned by your main agent to handle tasks in parallel. Think of them as workers your agent delegates to.
Why Sub-Agents?
- Parallelism — do multiple things simultaneously
- Isolation — each sub-agent has its own context
- Different models — use a cheaper model for simple tasks
- Long-running tasks — don't block the main conversation
Master this topic with hands-on labs
Go beyond reading — build real projects in sandboxed environments with expert video guidance.
Browse Courses →Spawning Sub-Agents
Your agent uses the sessions_spawn tool:
sessions_spawn(
task: "Research the top 5 Kubernetes alternatives and summarize each",
mode: "run" // One-shot task
)Run Mode vs Session Mode
run— complete the task and return results (one-shot)session— persistent session for ongoing interaction
Real-World Examples
Research Assistant
"Spawn a sub-agent to research OpenClaw competitors.
I need: name, pricing, key features, and limitations
for each. Return a comparison table."Code Review
"Spawn a sub-agent to review the PR diff I just pasted.
Check for security issues, performance problems, and
code style violations."Content Generation
"Spawn 3 sub-agents:
1. Write a blog post about Docker networking
2. Write a blog post about Docker volumes
3. Write a blog post about Docker security
Return all three when done."Managing Sub-Agents
List Active Sub-Agents
subagents(action: "list")Steer a Running Sub-Agent
subagents(action: "steer", target: "session-123",
message: "Also include pricing information")Kill a Sub-Agent
subagents(action: "kill", target: "session-123")Get weekly IT automation tips
Docker, Ansible, Terraform, MLOps — curated insights delivered to your inbox. No spam.
Subscribe Free →Best Practices
- Clear task descriptions — sub-agents don't have your conversation context
- Set timeouts — prevent runaway tasks
- Use run mode for one-shot tasks — cleaner than persistent sessions
- Don't over-parallelize — each sub-agent uses API tokens
- Review results — sub-agents work independently, verify their output
Cost Considerations
Each sub-agent session uses LLM tokens. For cost efficiency:
- Use cheaper models for simple tasks (model: "gpt-4o-mini")
- Keep task descriptions concise
- Set cleanup: "delete" to clean up after completion
---
Ready to go deeper? Check out our hands-on course: OpenClaw Agent — practical exercises you can follow along on your own machine.
Related guide
Related reading: the Ansible intelligent assistant and MCP server covers this in real-world detail.
Ready to learn by doing?
Stop reading tutorials — start building. Expert video courses with hands-on labs in real sandboxed environments.
Related Articles
OpenClaw Volume Permissions Fix
Fix OpenClaw Docker volume permission errors. Resolve EACCES issues for named volumes and bind mounts with troubleshooting steps.
Troubleshoot OpenClaw Gateway Errors
Fix OpenClaw gateway errors: 401 unauthorized, connection refused, origin not allowed, and WebSocket failures with resolution guides.
OpenClaw Reverse Proxy with Caddy
Set up HTTPS for OpenClaw using Caddy reverse proxy. Automatic TLS certificates, WebSocket support, and production config.
OpenClaw + Tailscale Remote Access
Access OpenClaw securely from anywhere using Tailscale. Zero port forwarding, zero firewall rules, encrypted connections.
OpenClaw + Telegram Bot
Connect your OpenClaw agent to Telegram for a personal AI assistant accessible from your phone. Setup guide with BotFather and configuration.
OpenClaw vs ChatGPT
Compare OpenClaw's self-hosted approach with ChatGPT and other cloud AI services. Learn the trade-offs between control, privacy, and convenience.
Explore topics
Browse more articles on the topics covered here.