Subagents library

save()

api.agents.subagents.save({ name, description, content, tools?, model? }) → Promise<Subagent>

Creates or replaces a subagent on the account. Its description is what the main agent reads when deciding whether to delegate.

always the accounttools and model optionaldescription decides
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

await api.agents.subagents.save({
  name: "explore",
  description: "Dig through files and data to answer a question, and report the facts.",
  tools: ["read", "list", "glob", "grep", "search", "fetch", "query_storage", "account"],
  model: "gemini-3.5-flash",
  content: [
    "Find what was asked. Quote exactly, with paths.",
    "Do not change anything.",
    "End with the facts, not with advice.",
  ].join("\n"),
});
api.agents.subagents.save(
    name="explore",
    description="Dig through files and data to answer a question, and report the facts.",
    tools=["read", "list", "glob", "grep", "search", "fetch", "query_storage", "account"],
    model="gemini-3.5-flash",
    content="\n".join([
        "Find what was asked. Quote exactly, with paths.",
        "Do not change anything.",
        "End with the facts, not with advice.",
    ]),
)
namestringrequired

Lowercase letters, digits and dashes.

descriptionstringrequired

One line, in the system prompt. It decides when the agent delegates to it.

contentstringrequired

Its instructions, up to 100 000 characters.

toolsstring[]

Its selection. Absent inherits the parent's.

modelstring

Its model. Absent inherits the parent's.

Writing a good one

  • Give it the narrowest tool set that can do the job — an investigator needs no write.
  • Tell it to report facts with paths and quotations: the parent sees none of its tool results.
  • Say what to do when it is blocked, since it cannot ask anyone.
  • A cheaper model is often right: a delegate reads a lot and decides little.
It starts with nothing

A subagent sees no part of the conversation — only the prompt the task call gives it. Its instructions should assume that, and the task call should carry the goal, the paths and exactly what to report.

It never writes to the disk

Same rule as skills: the disk is a read-only source, and a developer's files stay theirs.