subagents/
Delegate focused work to hook-composed child agents.
Subagents live under subagents/<name>/, each with its own instructions.md
and agent.ts. A child uses the same defineAgent() plus synchronous hook
model as its parent, but gets an isolated durable run and conversation-scoped
control state.
// subagents/researcher/agent.ts
import { defineAgent, useModel, useReasoning, useTool } from "@assemblyline-agents/core";
export default defineAgent({
description: "Use this subagent for scoped research tasks.",
maxReasoning: "low",
setup() {
useModel("openai/gpt-5.4-mini");
useReasoning("low");
useTool("search_docs");
}
});The description is parent-facing when-to-use guidance. Every child must select
exactly one model in setup(); models do not implicitly inherit from the
parent.
description is required for a subagent. workspace and connections add
child-specific limits. Other static fields, including maxReasoning and
maxIterations, use the same contract as the parent.
| Field | Effect |
|---|---|
description | Required guidance shown to the parent. |
workspace | Static sandbox/workspace adapter ceiling. |
connections | Names the child is permitted to select with useConnection(). |
maxReasoning, maxIterations | Shared agent fields that set hard runtime ceilings. |
The child selects tools, skills, connections, output schema, sandbox profile, reasoning, and model through hooks. Its named references must exist in the parent artifact's compiled capability catalog.
import { adapter, defineAgent, useConnection, useModel, useTool } from "@assemblyline-agents/core";
export default defineAgent({
description: "Use this for durable coding sessions.",
workspace: adapter("local"),
connections: ["github"],
setup() {
useModel("openai/gpt-5-codex");
useConnection("github");
useTool("read");
}
});Exposing And Invoking A Subagent
The parent must call useSubagent("researcher") before that child is visible.
The parent model then calls the snapshot-scoped delegate_<name> tool; authored tools may call
ctx.spawnSubagent(...) directly:
await ctx.spawnSubagent({
name: "researcher",
task: "Summarize the three most recent issues.",
expectedOutput: "A markdown summary with issue links.",
constraints: ["Read-only: do not comment on issues."]
});Realtime services remain connections and typed tools, not child-agent engines. The runtime enforces connection authorization and tool approvals independently for the child.