Agent options
agent(prompt, opts?) takes these options. All are optional.
label and phase are for display only. They are not part of the cache key, so renaming an agent does not make it run again on resume.
Schemas
A schema’s root must be an object, and every name inrequired must be in properties. An invalid schema makes agent() throw.
The answer is checked against the schema you wrote. If the model’s answer does not fit after a second attempt, the agent returns null.
The built-in tools
Without atools option an agent gets the read-only set.
Read-only agents are confined to the working directory:
read_file and the path arguments of bash commands cannot leave it. bash rejects shell metacharacters, so a command cannot be chained or redirected.
The write set is available only with isolation: 'worktree'.
Asking for a write tool without isolation makes
agent() throw.
Commands an agent runs through bash or shell do not see ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.
Agents that write code
- Creates a git worktree under
.maestro/worktrees/on a new branchwf/<runId>/<label>. - Runs the agent there. It cannot touch your checkout.
- When the agent finishes, checks in git that the branch exists, the worktree is clean and there is at least one new commit.
- Adds
branchNameto the agent’s result, so your script can hand the branch to a coordinator.
null; the worktree is kept for you to inspect, and its path is written to the log.
node_modules and build output are not copied into a worktree. Tell writers not to install packages.
Two agents cannot write to the same branch: give writers different labels.
maestro gc lists leftover worktrees and wf/* branches. See Command line.
Your own tools
To give agents something the built-ins do not cover, such as a paper search, a database or an internal API, define a tool in a file outside the script. The script only names it.- Tools are loaded from
.maestro/tools/, or from the directory given with--tools-dir. Each*.jsor*.mjsfile default-exports one tool or an array of tools. Files whose names start with_or.are helpers and are not loaded as tools. - Definitions are checked before the run starts. A bad one stops the run from starting. The name must not clash with a built-in or another tool,
writemust be stated, and the input schema must be strict: every object hasadditionalProperties: falseand lists every property inrequired. Make an optional field nullable instead of leaving it out. - A tool with
write: trueis a write tool and needsisolation: 'worktree'. runreturns a string. Throwing reports an error to the agent.
examples/tools/arxiv_search.js. It needs no API key; copy it into .maestro/tools/ to use it.
What to know before adding tools
- Tool code runs in Maestro’s own process, not in the script’s restricted context. It can reach the network. Giving a read-only agent a tool that reaches the network means the agent can send out what it reads.
- Files in
.maestro/tools/are executable code, like the scripts in apackage.json. Maestro loads them when a run starts, and the MCP server loads them whenever it lists its tools. Run Maestro only in repositories you trust. - The cache key holds a tool’s name, not its code. Changing a tool’s code does not invalidate earlier answers. Deleting a tool a run used breaks that run’s resume.