AI & Agents

How to Configure and Run OpenClaw Subagents

OpenClaw's subagent system lets you spawn isolated background agents that run tasks in parallel and announce results back when they finish. A workflow that takes 45 seconds serially can drop below 20 seconds with properly structured concurrent subagents.

Fast.io Editorial Team 13 min read
Subagents operate in their own sessions and announce results back to the requester.

What OpenClaw Subagents Actually Do

Only 36% of ClawHub skills pass security audits without issues, according to a 2026 analysis of the marketplace's 13,700+ community-built skills. That stat matters here because subagents inherit tool access from your configuration, and misconfigured tool policies can expose your entire gateway to untrusted skills running at depth. Understanding exactly how subagents work, what they can access, and how to restrict them is not optional.

OpenClaw subagents are isolated background agent runs that operate in their own sessions. You describe a task, the system spawns a new agent run, and that run executes independently from the parent. The spawn call is non-blocking: the parent gets confirmation immediately and can continue its own work while the subagent processes in the background.

This is different from sending a message to another agent. Each subagent gets its own context window, its own tool access governed by depth-based policies, and its own token budget. When it finishes, OpenClaw delivers a completion event back to the parent that includes the subagent's final reply, status, runtime statistics, and cost estimate.

The practical payoff is parallelism. If your main agent needs to research three topics, generate a report, and check file permissions, those five tasks can run simultaneously as subagents instead of sequentially. The parent spawns each one, yields until they complete, then synthesizes the results.

Visualization of subagent sessions running in parallel

How to Configure Subagent Defaults and Limits

Before spawning any subagents, you need the right gateway configuration. The defaults live under agents.defaults.subagents in your gateway config, and per-agent overrides go in agents.list[].subagents.

Here are the settings that matter most:

maxSpawnDepth controls how deep subagents can nest. Range is 1 to 5. Set it to 1 and subagents are leaf workers that cannot spawn their own children. Set it to 2 and depth-1 subagents become orchestrators that can delegate further. The official docs recommend depth 2 for most orchestrator patterns. Going beyond 3 adds complexity without proportional benefit in almost every case.

maxConcurrent caps the total number of subagent runs across all agents in your gateway. The default is 8, which is the global lane limit. If you have three agents each trying to spawn four subagents simultaneously, the ninth spawn queues until a slot opens. Size this based on your hardware and API rate limits, not ambition.

maxChildrenPerAgent limits how many active children a single session can have. Default is 5, range is 1 to 20. This prevents a runaway orchestrator from consuming all concurrent slots.

runTimeoutSeconds sets a hard stop for subagent runs. Default is 0 (no timeout). For production workloads, always set a timeout. A subagent stuck in a loop with no timeout will hold a concurrency slot indefinitely.

delegationMode accepts suggest or prefer. In suggest mode, the agent decides whether to delegate or handle the task itself. In prefer mode, the agent is nudged toward delegation when the task fits a subagent pattern.

A working configuration looks like this:

{
  "agents": {
    "defaults": {
      "subagents": {
        "maxSpawnDepth": 2,
        "maxConcurrent": 8,
        "maxChildrenPerAgent": 5,
        "runTimeoutSeconds": 900,
        "delegationMode": "suggest",
        "announceTimeoutMs": 120000,
        "archiveAfterMinutes": 60
      }
    }
  }
}

The announceTimeoutMs (default 120000, or 2 minutes) controls how long the gateway tries to deliver a completion event before giving up. The archiveAfterMinutes (default 60) auto-archives finished subagent transcripts after an hour.

Per-Agent Overrides

Individual agents can override the global defaults. The most common override is allowAgents, which controls which agent IDs a subagent can target with sessions_spawn.

By default, a subagent can only target the same agent it belongs to. Setting allowAgents: ["*"] lets it target any configured agent. For a tighter setup, list specific agent IDs:

{
  "agents": {
    "list": [
      {
        "id": "orchestrator",
        "subagents": {
          "allowAgents": ["researcher", "writer", "reviewer"],
          "delegationMode": "prefer"
        }
      }
    ]
  }
}

If your orchestrator also needs to spawn tasks targeting itself (for self-delegation), include its own ID in the allowAgents list.

How to Spawn and Control Subagent Runs

The sessions_spawn tool is how you create a subagent. It accepts a task description and several optional parameters that control how the subagent behaves.

Required parameter:

  • task (string): The task description. This is the only required field. Write it like a clear brief, not a vague hint. "Research the top 5 competitor pricing pages and summarize each in 3 bullets" works. "Look into competitors" does not.

Key optional parameters:

  • taskName (string): A stable handle matching [a-z][a-z0-9_]{0,63}. Useful for referencing the subagent programmatically in logs and status checks.
  • context: Either "isolated" (default) or "fork". This is the single most important choice after the task itself. More on this below.
  • model (string): Overrides the model for this specific subagent run. Useful for cost optimization, like spawning a cheaper model for simple extraction tasks.
  • thinking (string): Overrides the thinking level. Match this to task complexity.
  • runTimeoutSeconds (number): Per-spawn timeout that overrides the global default.
  • agentId (string): Target a different configured agent, if allowAgents permits it.
  • thread (boolean, default false): When true, requests a channel thread binding for this subagent session.
  • cleanup: Either "delete" or "keep" (default). Setting "delete" archives the subagent transcript after it announces its result.
  • sandbox: Either "inherit" (default) or "require". Setting "require" enforces sandboxed execution even if the parent doesn't use it.

After calling sessions_spawn, you get back { status: "accepted", runId, childSessionKey } immediately. The subagent is now running in the background.

Fork vs Isolated Context: When to Use Each

This is the trade-off most guides gloss over.

Isolated (default) creates a fresh session. The subagent only knows what you tell it in the task parameter. Use isolated when the subagent is doing independent research, generating content from scratch, or performing a task that does not depend on what the parent was just discussing. Lower token usage because the child transcript starts empty.

Fork branches the parent's entire transcript into the child session. The subagent sees everything the parent saw up to the spawn point. Use fork when the child genuinely needs prior conversation context, like when the parent just analyzed a document and the subagent needs to act on that analysis without re-reading the document.

The official docs say "use sparingly" about fork mode, and they mean it. Forking copies the full parent transcript into the child, which multiplies token consumption. If your parent agent has a 50,000-token conversation, every forked child starts with that same 50,000 tokens.

Thread-bound spawns (thread: true) default to fork mode automatically because thread responses typically need conversational context.

Fastio features

Persist Subagent Output Across Sessions

OpenClaw subagents generate files that disappear when sessions end. Fast.io gives your agents 50GB of persistent, searchable workspace storage with built-in RAG, no credit card required.

Tool Policies by Depth and the Announce Chain

OpenClaw restricts what tools subagents can access based on their nesting depth. The deeper a subagent sits in the spawn hierarchy, the fewer capabilities it receives. Your main agent session has full tool access, but subagents at each subsequent level lose session management tools progressively. Leaf workers at the deepest level get only standard tools like file operations and web search, with no ability to spawn further children or interact with other sessions.

This layered restriction serves as a security boundary. When your subagents pull in ClawHub skills from the 13,700+ marketplace, depth-based policies prevent an untrusted skill from spawning its own subagents or accessing session management capabilities it should not have. You can tighten this further with explicit allow and deny lists in your gateway configuration, specifying exactly which tools are available at each depth.

The general principle: grant the minimum tool surface each subagent needs, and rely on OpenClaw's depth restrictions as a backstop. Review the official subagent documentation for the exact tool matrix at each depth level and configuration syntax for custom policies.

Audit log showing subagent tool access and completion events

How the Announce Chain Works

When a subagent finishes, it does not just silently exit. The completion event travels up the nesting chain:

  1. A depth-2 worker completes and announces to its depth-1 orchestrator
  2. The depth-1 orchestrator receives the result as an in-session follow-up (not a new visible message)
  3. When the orchestrator finishes its own work, it announces to the main agent (depth 0)
  4. The main agent synthesizes results and responds to the user

Completion events include the subagent's final reply text, status (completed, failed, timed out, or unknown), runtime and token statistics, and estimated cost. Failed runs do not reuse captured reply text.

If the parent run is still active when a child completes, OpenClaw tries to wake and steer that run directly rather than starting a new reply path. This keeps the conversation coherent.

Two special tokens control announce behavior: if a subagent replies with ANNOUNCE_SKIP, nothing gets posted. If the last assistant message is exactly NO_REPLY, the announce is suppressed. These are useful for background maintenance tasks that should not surface results.

Practical Orchestrator Pattern with Persistent Storage

The real power of subagents shows up when you combine parallel execution with persistent storage. Here is a concrete pattern: a research orchestrator that spawns three subagents in parallel, collects their results, and stores the output in a shared workspace.

The orchestrator agent receives a task like "Research competitor pricing for X, Y, and Z." It spawns three isolated subagents, one per competitor. Each subagent searches the web, gathers pricing data, and writes a summary. The orchestrator calls sessions_yield to wait for all three completions, then synthesizes a combined report.

Without persistent storage, that report exists only in the orchestrator's context window. When the session ends, it is gone. For one-off questions that is fine. For a team that runs this research weekly, you need the output somewhere durable.

Local filesystems work if every agent runs on the same machine, but they break the moment you scale to multiple containers or need to share results with humans. Object storage (S3, GCS) adds durability but not searchability. You upload a PDF and can retrieve it by key, but you cannot ask "what was the pricing trend we found last month?" without building your own retrieval layer.

Fast.io workspaces fill this gap by combining file storage with built-in intelligence. Upload the research report and it is automatically indexed for semantic search and RAG queries. A human teammate can open the workspace, ask Ripley AI "what did the competitor analysis find about enterprise pricing?", and get a cited answer pointing to the exact file and passage.

The agent side uses the Fast.io MCP server to write files directly into a shared workspace. No local disk, no manual transfer. The orchestrator spawns subagents, collects results, generates the report, and uploads it to the workspace in a single pipeline.

For teams running OpenClaw agents that produce files (reports, datasets, generated code, analysis artifacts), the handoff problem is just as important as the orchestration problem. Fast.io's free agent plan includes 50GB storage, 5,000 credits per month, and 5 workspaces with no credit card required. Enough to persist subagent output from day one.

Fast.io workspace showing files uploaded by multiple agents

How to Monitor and Debug Subagent Runs

OpenClaw provides slash commands for inspecting subagent state without leaving your chat session.

/subagents list shows all subagent runs for the current session, including their status, run IDs, and task names.

/subagents log <id> [limit] [tools] dumps the transcript for a specific subagent run. Add the tools flag to include tool call details. The limit parameter caps how many entries you see.

/subagents info <id> displays run metadata: model used, tokens consumed, runtime, status, and session key.

For Discord users, /focus <target> binds a thread to a specific subagent session so you can interact with it directly. /unfocus removes the binding.

Common problems and fixes:

Subagent stuck with no output: Check runTimeoutSeconds. If set to 0 (no timeout), a subagent in a loop will never terminate. Set a reasonable timeout for every production deployment.

Announce not delivered: Announce delivery is best-effort. A gateway restart loses pending announces. If you restart the gateway while subagents are running, their results may not reach the parent. For critical workflows, check /subagents list after a restart to see if any runs completed during downtime.

Concurrent slot exhaustion: If spawns are queuing unexpectedly, check maxConcurrent (global cap, default 8) and maxChildrenPerAgent (per-session cap, default 5). Reduce the number of parallel spawns or increase the limits if your hardware supports it.

Context injection missing: Subagents only receive AGENTS.md and TOOLS.md from the gateway context. They do not get SOUL.md, IDENTITY.md, USER.md, MEMORY.md, HEARTBEAT.md, or BOOTSTRAP.md. If your subagent needs personality or memory context, pass it explicitly in the task parameter or use fork mode.

Cascading stops: Running /stop on a parent agent stops all its child subagent runs. This is intentional but can surprise you if a parent and child are working on unrelated follow-up tasks.

Frequently Asked Questions

How do I create a subagent in OpenClaw?

Call `sessions_spawn` with at minimum a `task` parameter describing what the subagent should do. The call returns immediately with a `runId` and `childSessionKey`. The subagent runs in the background and announces its result back to your session when it completes. Use `sessions_yield` to pause your current run and wait for subagent completions if you need results before continuing.

What is the difference between fork and isolated context in OpenClaw subagents?

Isolated context (the default) starts the subagent with a clean transcript. It only knows what you include in the `task` parameter. Fork context copies the parent's entire conversation history into the child session, so the subagent can reference prior discussion, tool results, and instructions. Fork costs more tokens because it duplicates the parent transcript. Use isolated for independent tasks and fork only when the child genuinely needs conversational context.

How many concurrent subagents can OpenClaw run?

The default global limit is 8 concurrent subagent runs, controlled by the `maxConcurrent` setting. Each individual agent session is also capped at 5 active children by default (the `maxChildrenPerAgent` setting, configurable from 1 to 20). Both limits are adjustable in the gateway configuration. The practical ceiling depends on your hardware resources and API rate limits.

Can OpenClaw subagents spawn their own subagents?

Yes, if `maxSpawnDepth` is set to 2 or higher. At depth 1, a subagent with sufficient spawn depth becomes an orchestrator that receives `sessions_spawn` and related session tools. It can then spawn depth-2 workers. Depth-2 subagents are always leaf workers and cannot spawn further children. The maximum supported depth is 5, though the official documentation recommends depth 2 for most patterns.

What happens when a subagent fails or times out?

OpenClaw still delivers an announce event to the parent, but the status field shows "failed" or "timed out" instead of "completed." Failed runs do not reuse the subagent's last reply text. The parent agent receives the failure status and can decide how to handle it, either by retrying, falling back to a different approach, or reporting the failure. Setting `runTimeoutSeconds` prevents subagents from running indefinitely.

How do I restrict which tools a subagent can use?

OpenClaw supports explicit allow and deny lists in your gateway configuration that control which tools subagents can access. Depth-based restrictions also apply automatically: subagents at deeper nesting levels receive progressively fewer capabilities, with leaf workers losing session management tools entirely. Check the official subagent documentation at docs.openclaw.ai/tools/subagents for the exact configuration syntax and per-depth tool matrix.

Related Resources

Fastio features

Persist Subagent Output Across Sessions

OpenClaw subagents generate files that disappear when sessions end. Fast.io gives your agents 50GB of persistent, searchable workspace storage with built-in RAG, no credit card required.