Skip to content

Multi-agent

The SDK supports lightweight supervisor/sub-agent delegation.

A sub-agent is a normal Agent wrapped as a delegate tool. The supervisor can call that tool, receive the sub-agent result, and continue its own loop.

This is intentionally small: it is not a distributed scheduler, workflow engine, or autonomous swarm runtime.

import {
createAgent,
createMultiAgent,
createSubAgent,
} from "@npm-while1/claude-agent-sdk";
const researcher = createSubAgent({
name: "researcher",
description: "Research SDK implementation details",
agent: createAgent({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/anthropic",
model: "deepseek-v4-flash",
}),
});
const team = createMultiAgent({
supervisor: createAgent({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/anthropic",
model: "deepseek-v4-flash",
}),
subAgents: [researcher],
});
const result = await team.prompt("Use the researcher to inspect the SDK design.");
console.log(result.result);

createMultiAgent() adds one tool to the supervisor for each sub-agent.

Sub-agent Supervisor tool
researcher delegate_researcher
code-review delegate_code-review

When the supervisor calls a delegate tool, the SDK runs the sub-agent with the delegated task and returns the sub-agent’s final result as the tool result.

Use the supervisor’s normal permission callback if your host wants to approve or deny delegation.