Managing one AI agent is useful, but managing a team of agents is the real shift for anyone serious about automation. In this guide, I'll explain how sub-agents work in OpenClaw and how to use them to delegate long or complex tasks in the background.
Sub-agents aren't just "more bots" to talk to. They are specialized workers that your main agent can create, instruct, and launch to solve a specific problem while it continues to handle the conversation with you.
What are Sub-agents in OpenClaw?
In OpenClaw, a sub-agent is an isolated session (a "child") generated by an active session (the "parent"). Unlike peer-to-peer agent teams (like in HiClaw), sub-agents have a clear hierarchy: they are born for a task, execute it, and report the result back to the requester.
Imagine asking your agent to analyze an entire GitHub repository. Instead of blocking the chat for 10 minutes, the agent can spawn a sub-agent specialized in code reading. The sub-agent works in its own space, gathers data, and once finished, "knocks" on the main chat with the full report.
For a deeper dive into the technical specs, you can check out the official OpenClaw sub-agents documentation.
Need help with AI integration?
Get in touch for a consultation on implementing AI tools and sub-agents in your business.
How They Work Technically: The sessions_spawn Tool
Everything happens through a specific tool called sessions_spawn. When the agent decides to delegate programming tasks, it calls this tool passing a few fundamental parameters:
- task: Specific instructions for the sub-agent.
- agentId: Which identity it should assume (e.g., "coder", "researcher").
- context: Whether it should inherit the current chat history (
fork) or start from scratch (isolated).
Once launched, the sub-agent lives in a separate session. This means it has its own memory limits, its own tools, and doesn't interfere with the parent agent's variables until the job is done.
# Example of how an agent sees the command internally
sessions_spawn(
agentId="researcher",
task="Analyze the last 10 news items about OpenClaw and summarize API changes",
context="isolated"
)When to Use OpenClaw Sub-agents
Not every task requires a sub-agent. Delegating adds a small overhead in terms of time and costs (tokens). Here is when it's the right choice:
- Parallel Tasks: Need to do three different web searches at once? Spawn three sub-agents.
- Tool Isolation: If a task requires writing many files or doing heavy scraping, it's better to do it in a "disposable" session to avoid cluttering the main context.
- Specialization: You can have a sub-agent configured with a specific
soul.mdfor debugging and one for copywriting, calling them only when needed.
Configuration and Best Practices for Sub-agents
To prevent the system from spinning out of control (agents creating infinite agents), OpenClaw uses the maxSpawnDepth parameter. By default, it's set to 1, meaning a sub-agent cannot create other sub-agents unless configured otherwise.
Here are some golden rules I follow in my setup to build an AI workforce using OpenClaw sub-agents:
- Clear Tasks: Don't give vague instructions. The sub-agent must have an atomic goal (e.g., "Find the email in this text" vs. "Help me with this project").
- Monitoring: Don't poll continuously. OpenClaw will automatically notify you when the sub-agent is finished via a message in the chat.
- Context Isolated: If the sub-agent doesn't need to know what you've said in the last 20 messages, use
context="isolated". You'll save tokens, and the sub-agent will be faster and more precise.
Conclusion
Sub-agents transform OpenClaw from a simple assistant into a full-fledged digital workforce orchestrator. In this 2026 landscape, starting to delegate repetitive tasks to child sessions is the first step in building AI systems that truly work for you, not just with you.
For context, an isolated OpenClaw sub-agent can typically process a web research task in 45-60 seconds while reducing parent token load by up to 70%. This efficiency is what allows me to manage complex workflows on this blog daily. When you use OpenClaw sub-agents, you are essentially offloading the "thinking" time to a specialized worker. This is why OpenClaw sub-agents are becoming the standard for enterprise automation. I've personally seen how OpenClaw sub-agents can handle multi-step research without clogging the main session.
If you've already set up OpenClaw, try asking your agent to "delegate the research of X to a sub-agent" and watch how it handles the workflow.
FAQ
What is the difference between Agents and Sub-agents?
Agents are independent entities you start a conversation with. Sub-agents are temporary "children" created during a conversation to perform a specific task and then close.
How do I know if a sub-agent is working?
OpenClaw tracks every spawn as a background task. You'll see a notification or indicator (depending on the interface, like Telegram or CLI) confirming the work has started.
Can I stop a sub-agent if it makes a mistake?
Yes, you can use the subagents tool with the kill action to terminate a child session before it finishes the task.
Written by Matteo Giardino, CTO and founder. I build AI agents for SMEs in Italy. My projects.
