Subagents

September 18, 2026 ยท View on GitHub

Give a parent agent a specialist it can call:

<<< @/snippets/travel-planner/subagent-basics.ts{ts twoslash}

The parent calls summarize like any other tool. The child gets that call's input, runs with its own instructions and conversation, and returns { output, budgetExhausted }. Its intermediate history stays out of the parent's context. Each agent can use its own model and toolkit.

Subagent.layer(delegation) requires a model: supply it with Layer.provide(model) or provide it around the parent program. An AutoModel selects from each new child's delegated task automatically. A shared selection store retains the child's choice for follow-ups; sibling threads select independently.

This defines the agents. Choose how to run them below.

Choose a setup

KindParent behaviorUse it when
In-memory attachedWaits for a tool result; child shares its ScopeRestarting the task after a process crash is acceptable
Durable attachedSuspends, then resumes with the child's resultThe parent needs the answer and progress must survive restarts
Durable backgroundContinues; receives declared updates and a completion reportThe user should keep chatting while work runs

Both attached forms use Summarize.tool. Durable execution comes from the host you run them on. For background work, expose start and follow-up tools instead:

import { Subagent } from "effect-agent";
import { Summarize } from "./subagent-basics.ts";
// ---cut---
const background = Subagent.background(Summarize.target, {
  start: true,
  followUp: true,
  reportToParent: true,
});

Give the parent background.toolkit and provide background.layer for its handlers. The background guide shows how findings become new input to the parent.

Lifecycle and limits

Attached children can run concurrently, but the parent's next model call waits for the batch to settle. A durable parent releases its execution slot while waiting and recovers the same child after a restart. Aborting the parent propagates cancellation to attached children.

Background workers keep running after the parent finishes or aborts. Follow-ups continue the same child thread. Durable hosts recover their accepted work and pending report delivery.

All three forms enforce permissions and budgets. Parent tools are not inherited. See the subagent reference for projections, nested delegation, and limits, or durability for recovery of uncertain external actions.

Looking for a section from the previous guide?

Child definitions, delegation tools, and model Layers live in the in-memory attached walkthrough.

Durable registration and recovery now live in the durable attached guide.

Starting workers, follow-ups, and replies now live in the background guide.

Advanced policies now live in the subagent reference.

Peer routes now live in Agent messaging.