Built-in agents
Explore and Plan can’t edit files or run commands. Since 0.4.34 they
can’t search either: searching means running rg with bash. Give them the
files to look at, or use General when the task needs a search. The tools a
subagent can have are read, ls, write, edit, bash, fetch,
web_search, git_info, your MCP tools, and agent for starting its own
subagents.
When the model starts a subagent without naming one, o4 starts a fork: a copy
of the main agent with the same context and tools. It’s listed as the built-in
Fork agent in /sub-agents.
Every subagent uses your current model unless something names another one.
o4 takes the first of these that is set:
- The
O4_SUBAGENT_MODELenvironment variable, a model reference for every subagent. - The model you chose for that agent on its Model row in
/sub-agents. - The model the main agent asks for when it starts the subagent.
- The
modelin the agent’s definition.
Watch and control subagents
While a subagent runs, its progress shows in the chat. PressDown in the
prompt to open the agent list, which shows
what each one is doing. Run /agents to open Ringside,
which lists every subagent in the session with its status. From there you can
open a subagent’s output, send it a message with m, or stop it with x. See
todos and background tasks
for all the keys.
A subagent that runs in the foreground for more than 2 minutes moves to the
background, and the conversation continues. The model can also start a
subagent in the background from the beginning. Either way, o4 tells the model
when it finishes. The auto_background_ms setting changes the 2-minute limit.
Approvals
A subagent’s tool calls go through approvals like the main agent’s. When a subagent needs approval, the status row saysAwaiting approval and names the
subagent that is waiting.
A custom agent can set its own permissionMode, described below.
Limits
- A subagent can start its own subagents, up to 3 levels deep.
- At most 10 subagents run at once by default. Set
max_concurrent_agentsin~/.o4/settings.jsonor.o4/settings.jsonto change this. - A subagent has no turn limit or time limit of its own. It runs until it finishes, you stop it, or a request or tool fails.
What the model passes to a subagent
The model starts a subagent with theagent tool. Besides the prompt, it
can pass:
When a
contract lists more than one file in touch_only, its done_when
command is the check, unless verify names another command or is false.
When the subagent stops, o4 runs the check. If it fails, o4 sends the
failure back to the subagent and lets it keep working. o4 does this at most
2 times, then accepts the result.
A check must be a test command: cargo test, pytest, go test or
npm test, with or without arguments. For it, o4 runs the tests that the
changes affect with the test_run tool, not the command as written. With
any other check command, the agent call fails before the subagent starts,
and the model can run the check itself with bash, where your approvals
apply. o4 doesn’t stop a subagent from editing files outside touch_only.
Run a subagent in its own worktree
The model can passisolation: "worktree" when it starts a subagent, and a
custom agent can set isolation: worktree. The subagent then works in its
own git worktree under .o4/worktrees/, on its own branch, so it can’t change
your checkout.
When the subagent finishes, o4 removes the worktree if it has no changes. If
it has changes, o4 keeps it and tells the model where it is, so the changes
can be reviewed and merged. o4 removes clean worktrees that haven’t been used
for 30 days when a session starts.
Custom agents
A custom agent is a Markdown file with YAML front matter. The front matter configures the agent, and the body is its system prompt.Where agent files live
If two files define the same
name, the project agent wins over your own,
and both win over a built-in agent with that name. o4 loads project agents
only after you trust the workspace. See
workspace trust.
o4 reads agent files when a session starts, and again after you create,
edit, or delete an agent through /sub-agents. If you change an agent file in
your own editor during a session, start a new session to pick up the change.
Agents that plugins provide are also available. See
plugins.
Front matter fields
o4 also accepts
maxTurns, initialPrompt, and omitClaudeMd, but in o4
0.4.23 they don’t change how the agent runs: subagents run until they finish,
whatever maxTurns says. /sub-agents shows maxTurns in the agent’s
details as Max turns.
Permission modes for custom agents
Manage agents with /sub-agents
Run/sub-agents to open the Agents browser. It lists every agent
definition with its description and source: built-in, user, project, or
plugin. Tab and Shift+Tab switch between the All, Project,
User, Built-in, Plugin, and Errors tabs. The Errors tab
lists agent files that failed to load. Type to filter the list, and press
Ctrl+U to clear the filter. You can also open the browser from the Agents tab
of /config, with its Open agent browser row.
Press Enter on an agent to see its details and actions, and Esc to go back
to the list. The details show the agent’s tools, permission mode and
maxTurns, and its memory scope if it has one. The actions are:
- Select agent fills the prompt with
Use the <name> agent for:so you can type the task. - Edit agent opens the file in your editor.
- Delete agent deletes the file right away, without asking.
- View system prompt shows the agent’s prompt as scrollable text, with
its number of lines on the row.
Escgoes back to the agent. - Model shows the model the agent runs on, or
Same as the main session. PressEnterto pick one from the model list. The first entry, Use the main session’s model, clears your choice. o4 says<name> will run on <model>and saves the choice insubagent_modelsin~/.o4/settings.json, never in the agent’s file, so it works for built-in agents too. Seesubagent_models.
Wait for the current turn to finish before making this change.
To create an agent, choose Create new agent at the top of the list. Type a
name, then pick the location: project (.o4/agents/, the default) or user
(~/.o4/agents/). o4 writes a starter file with name, description, and a
one-line prompt, and opens it in your editor: $EDITOR, then $VISUAL, then
vi.
You can also go straight to an action:
create (or new) opens the create form with the name filled in. select,
edit, and delete open that agent with the action highlighted; press
Enter to run it.
Teams
For larger jobs, the model can organize subagents into a team. Theteam_create tool sets up a named team under .o4/teams/<name>/ with a
roster of 1 to 10 members and a mailbox for each. It doesn’t start any
agents. Calling it again for a team the session leads adds or updates
members. team_delete removes the team.
The send_message tool delivers a message to a running subagent by its
name, or to a team member (<name>@<team>), or to a team, which reaches
its lead. Messages reach a subagent at its next tool call rather than in the
middle of a response. For a subagent that has finished, the model can pass
resume: true: o4 restarts the subagent in the background from its saved
conversation, with the message added.
A team member can also run in a terminal of its own. Start o4 there with
o4 --as <name>@<team>, for example o4 --as scout@alpha. That session
reads the member’s mailbox between turns and replies to the team’s lead with
send_message. o4 reads team mail only in a
trusted workspace.
team_create and team_delete ask for approval every time. send_message
asks once per session.
Related pages
- Campaigns: split one objective across parallel workers.
- Plan mode: research before you change anything.
- Permissions: approval modes for the main agent.