In This Article
Introduction
sessions_spawn and sessions_send are OpenClaw primitives that enable inter-agent communication. One agent can spawn another with a specific task and context, or send a message to an existing agent session. This is the mechanism behind the Multi-Agent Content Factory: Research Agent completes → spawns Writing Agent with TOPICS.md path → Writing completes → spawns Thumbnail Agent. Without these primitives, agents would be siloed. With them, you build pipelines, chains, and coordinated workflows.
This post explains sessions_spawn and sessions_send, when to use each, and how they power multi-agent patterns. If you're building multi-agent workflows, these are the building blocks.
sessions_spawn
sessions_spawn creates a new agent session with specified config: which agent (by AGENTS.md entry), initial instruction, memory path. The spawning agent continues; the spawned agent runs asynchronously. Think of it like fork() — the parent keeps going, the child runs in parallel. When the spawned agent completes, it can spawn another — creating chains. Research → Writing → Thumbnail is a chain. Each step hands off to the next.
Parameters typically include: agent name (from AGENTS.md), initial message/instruction, optional memory path to pass context. The spawned agent gets a fresh session. It doesn't inherit the parent's conversation history — you pass what it needs via the initial instruction. This keeps sessions clean and avoids context bleed.
sessions_send
sessions_send delivers a message to an existing session. Use when agents need to coordinate in real time — e.g., "Strategy Agent sends updated goals to Execution Agent." The receiving agent processes the message in its next cycle. Unlike spawn, send doesn't create a new session. It adds to an existing one. The receiving agent sees the message as new input and can act on it.
Use send when: (1) you have a long-running agent that needs updates — e.g., a monitor that receives new thresholds; (2) agents need to pass information without spawning a new workflow — e.g., "here's the updated spec"; (3) you want to avoid the overhead of spawning — send is lighter than spawn. Use spawn when you need a new workflow, a new agent type, or a handoff to a different capability.
Use Cases
Content Factory: Research → Writing → Thumbnail pipeline. Research Agent gathers sources, writes TOPICS.md, spawns Writing Agent with the path. Writing Agent produces the draft, spawns Thumbnail Agent with the content. Each agent does one job. The chain produces a complete content package.
Infrastructure: Monitor agent detects anomaly → spawns Fix agent with context. The Fix agent has access to logs, metrics, and a clear instruction: "investigate and remediate." When done, it can spawn a Report agent to summarize. Reef-style patterns.
Delegation: Generalist agent spawns specialist for complex sub-task. "This requires deep research — spawn Research Agent." "This needs code — spawn Dev Agent." The generalist stays in the loop; the specialist does the heavy lifting.
Content Factory Example
Concrete flow: (1) User asks: "Write a blog post on X." (2) Orchestrator spawns Research Agent: "Research X, output TOPICS.md." (3) Research completes, spawns Writing Agent: "Write blog from TOPICS.md at path Y." (4) Writing completes, spawns Thumbnail Agent: "Create thumbnail for blog at path Y." (5) Thumbnail completes. Orchestrator assembles and returns. Each agent is focused. The handoffs are explicit. sessions_spawn is the glue.
Best Practices
Pass context explicitly: Don't rely on shared memory unless you've designed for it. Pass paths, IDs, or summaries in the initial instruction. Keeps sessions decoupled.
Handle failures: Spawned agents can fail. Design for it. Timeouts, retries, fallback to human. Don't assume the chain always completes.
Avoid spawn storms: Spawning many agents in parallel can overwhelm. Use spawn for sequential handoffs; use send for lightweight updates. Batch when possible.
Wrapping Up
sessions_spawn and sessions_send are the glue for multi-agent workflows. See multi-agent and Content Factory for patterns. If you're building agent pipelines, these primitives are essential.