Skip to slide
Chapter 11 · Subagents and Multi-Agent Orchestration
74 / 142

CHAPTER 11 · Subagents and Multi-Agent Orchestration · 2 / 10

Foreground vs background, and the contract

Subagents run in one of two modes. Foreground blocks until done and returns the result, good for sequential work where you need the output now. Background returns immediately and works independently, good for long-running or parallel workstreams. Cursor lets you launch several at once for throughput, and (since version 2.5) subagents can even launch their own child subagents, up to a nesting limit.

The thing that makes orchestration reliable is the contract, pillar 4. Each subagent gets a clear input (a self-contained prompt, because it has no access to the parent's history) and returns a structured output the next step can consume. The "Seven Pillars" breakdown is strict about this: define explicit contracts so a subagent does one thing, does it in isolation, and returns a predictable shape. Codex exposes the lifecycle as primitives: spawn_agent, wait_agent, send_message, close_agent. Each subagent has its own context and sandbox.

← → arrow keys work too