Skip to content

Subagent

Delegates a self-contained task to a child agent that runs in its own context and returns a final report. Use it when a subtask would otherwise flood the parent’s context with intermediate work and you only need the conclusion. The model writes the task each time it calls the tool; the child cannot ask follow-up questions, so the task must include all the context it needs.

The make_subagentmakeSubagent factory uses axis policies to control what the model can configure on each child. The configurable axes are instructions, tools, model, and context. The parent also passes a task to the child.

By default, the child sees only the task (context=Fixed("none")context: new Fixed('none')), but you can share the parent’s conversation by setting context to a Choice over "none", "all" (full history including tool calls), and "no_tools" (text turns only). When a non-"none" option is available, the model can also pass last_messages to limit how many parent messages to share.

Supported in: Python, TypeScript (Node.js, browsers).

Quickstart example:

import { Agent } from '@strands-agents/sdk'
import { subagent } from '@strands-agents/sdk/vended-tools/subagent'
const agent = new Agent({
systemPrompt: 'You are a manager.',
tools: [subagent],
})
await agent.invoke('Research the latest TypeScript 5.x features and summarize them.')

Example — full control with make_subagentmakeSubagent:

import { Agent } from '@strands-agents/sdk'
import { Choice, Option, Preset } from '@strands-agents/sdk/multiagent'
import { makeSubagent } from '@strands-agents/sdk/vended-tools/subagent'
const subagent = makeSubagent({
presets: {
researcher: new Preset({
instructions: 'You research topics thoroughly.',
description: 'deep research on a topic',
}),
reviewer: new Preset({
instructions: 'You review code for correctness and style.',
description: 'code review',
}),
},
model: new Choice([
new Option('fast', 'global.anthropic.claude-sonnet-4-6', 'quick tasks'),
new Option('deep', 'global.anthropic.claude-opus-4-6-v1', 'hard problems'),
]),
context: new Choice(['none', 'all', 'no_tools']),
tools: new Choice(['read', 'shell', 'write'], true),
maxDepth: 3,
})
const agent = new Agent({ tools: [subagent] })
await agent.invoke('Review the changes in src/main.ts for correctness.')

Full API reference: TypeScript