AgentDelegate work to a subagent.
CLI/SDK tool; own context and subagent allow/deny limits. Named calls can address teammates; forks and remote isolation have separate gates.
Aliases and version differences: Task (accepted compatibility alias; SDKSystemMessage init may still report Task, per publisher SDK docs)
InputPublished TypeScript
| Field | Type | Required | Meaning and defaults |
|---|---|---|---|
description | string | Yes | A short (3-5 word) description of the task |
prompt | string | Yes | The task for the agent to perform |
subagent_type | string | No | The type of specialized agent to use for this task |
model | "sonnet" | "opus" | "haiku" | "fable" | No | Optional model override for this agent. Takes precedence over the agent definition's model frontmatter and the configured default subagent model. If omitted, uses the agent definition's model, else the default (inherits from the parent unless a default subagent model is configured). Ignored for subagent_type: "fork" — forks always inherit the parent model. |
effort | "low" | "medium" | "high" | "xhigh" | "max" | No | Reasoning effort for this agent. Set this ONLY when the user, or instructions such as CLAUDE.md or a skill, explicitly ask that this agent or delegated work run at a specific effort level, never on your own judgment; otherwise omit it and the agent runs at its usual effort. Ignored for subagent_type: "fork": a fork runs at your own effort. |
run_in_background | boolean | No | Agents run in the background by default; you will be notified when one completes. Set to false only when your very next action depends on this agent's result and nothing else could usefully happen while it runs — otherwise leave it in the background so the user can hand you other work. |
name | string | No | Name for the spawned agent. Makes it addressable via SendMessage({to: name}) while running. |
team_name | string | No | Deprecated; ignored. The session has a single implicit team. |
mode | "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan" | No | Deprecated; ignored. Subagents inherit the parent session's permission mode; agent-definition frontmatter may override it. |
isolation | "worktree" | "remote" | No | Isolation mode. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo. "remote" launches the agent in a remote cloud environment (always runs in background; availability is gated). |
Full input definition
export interface AgentInput {
description: string;
prompt: string;
subagent_type?: string;
model?: "sonnet" | "opus" | "haiku" | "fable";
effort?: "low" | "medium" | "high" | "xhigh" | "max";
run_in_background?: boolean;
name?: string;
team_name?: string;
mode?: "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan";
isolation?: "worktree" | "remote";
}ResultPublished TypeScript
Full result definition
export type AgentOutput = {
agentId: string;
agentType?: string;
content: {
type: "text";
text: string;
citations?: unknown[] | null;
}[];
resolvedModel?: string;
modelsUsed?: string[];
totalToolUseCount: number;
totalDurationMs: number;
totalTokens: number;
usage: {
input_tokens: number;
output_tokens: number;
cache_creation_input_tokens: number | null;
cache_read_input_tokens: number | null;
server_tool_use: {
web_search_requests: number;
web_fetch_requests: number;
} | null;
service_tier: string | null;
cache_creation: {
ephemeral_1h_input_tokens: number;
ephemeral_5m_input_tokens: number;
} | null;
inference_geo?: string | null;
speed?: string | null;
iterations?: unknown;
output_tokens_details?: {
thinking_tokens?: number | null;
} | null;
fallback_credit?: unknown;
};
toolStats?: {
readCount: number;
searchCount: number;
bashCount: number;
editFileCount: number;
linesAdded: number;
linesRemoved: number;
otherToolCount: number;
frameCount?: number;
};
status: "completed";
prompt: string;
worktreePath?: string;
worktreeBranch?: string;
} | {
status: "async_launched";
isAsync?: true;
agentId: string;
description: string;
resolvedModel?: string;
modelsUsed?: string[];
prompt: string;
outputFile: string;
canReadOutputFile?: boolean;
} | {
status: "remote_launched";
taskId: string;
sessionUrl: string;
description: string;
prompt: string;
outputFile: string;
};