Skip to main content

Module agent_spawn

Module agent_spawn 

Source
Expand description

POST /api/v1/agent/spawn, the Agents tool’s spawn (docs/specs/SPEC_AGENT_WORKERS_2026_10_15.md §3.1, Phase A): the calling agent, the leader, opens a worker: a new agent built from its own definition, on the model it names, in a pane to the right of its own. A worker is not a fork (the pane’s Fork, an exact copy that carries the conversation): it isn’t among the leader’s forks, and starts without the leader’s conversation or Personal Memory, with the leader’s definition (instructions, skills), Global Memory and, from the MCP server, the brief it is sent as the leader’s own message.

Launching an agent spends tokens until someone stops it, so (§3.5): only a verified agent spawns, host or container (a container leader gets container workers: same image, each with its own container and workspace), a worker doesn’t, a leader has at most MAX_LIVE_WORKERS, and unless the user’s own turn asked for it the user is told first, in the leader’s pane, by a card with a countdown that goes ahead on its own (announce_start).

Modules§

container 🔒
Where a new agent runs: the runtime, container_image, memory_mb and cpus of Agents spawn (a worker) and Agents create (a named agent from a template).
create 🔒
POST /api/v1/agent/create, the Agents tool’s create: a named agent made from a seeded template, the way the new-agent picker makes one (agentdefcreatefromtemplate), so an agent can add to My Agents without the operator’s hands. It is not a worker: it has no leader, takes no place among the caller’s live workers, can be given a seat (Agents set_seat) and is started with Agents open.
import 🔒
POST /api/v1/agent/import, the Agents tool’s import: an agent archive (.abf, kind agent, written by Agents export) put in My Agents (SPEC_MOVE_AN_AGENT_TO_ANOTHER_COMPUTER section 4 and 7, step B of the build).
many 🔒
POST /api/v1/agent/spawn_many, the Agents tool’s spawn with workers (SPEC_COUNTDOWN_BUTTONS_AND_BATCH_AGENT_ACTIONS_2026_10_28.md §5): several workers at once, one approval for all of them, and all of them or none. Everything that can be checked is checked before the first worker is made (the briefs, the names, the accounts, the leader’s limit, the room under the agent cap); a launch that still fails removes the workers already launched. The MCP process sends the briefs only after srv answers that all of them are open.
route 🔒
The harness, model route and model a new agent is asked to run on, for spawn, spawn_many and create (docs/specs/SPEC_AGENT_MODEL_ROUTES_ANY_MODEL_SPAWN_AND_SWITCH_2026_11_06.md sections 3 and 5). The rules are model_gateway::ask’s; this adds what a spawn knows: the leader, its remembered runtime and the Vault.
team 🔒
Where a leader’s workers open: a tab of their own, “ team”, in the leader’s workspace, made the first time and reused after. Without it a leader that lives in the user’s main tab fills that tab with its workers.

Structs§

Leader 🔒
The leader as srv knows it: its pane and its definition.
SpawnAgentResult 🔒
SpawnError 🔒
WorkerAccount 🔒
The account a worker runs on.
WorkerRuntime 🔒
The worker’s remembered runtime (agentlastruntime): the leader’s, with the requested model and effort over it.
WorkerSummary 🔒
One of a leader’s workers, for Agents workers (§3.4).

Constants§

COACHED_BY_META_KEY 🔒
The worker pane’s leader, {agent, id, block_id}: the leader’s name, its definition id and its pane. srv writes it when it opens the worker; no client can (browser_owner::srv_only_keys).
CREATED_BY_CONTENT 🔒
The agent that made this one with Agents create, {agent, id}, kept on the new agent’s definition (agent content) so that agent can delete it again (Agents delete). srv writes it; a client may not, and a fork does not inherit it.
MAX_LIVE_WORKERS 🔒
Live workers a leader may have at once (§3.5).
MAX_NAME_CHARS 🔒
RUN_ACCOUNT_META_KEY 🔒
The account a pane’s run launched on (agent_state::RUN_ACCOUNT_META_KEY). The account a pane’s run launched on, written at spawn (build_persistent_spawn_env), so a failure that run records counts against that account even after the agent is linked to another (run_accounts_of_block).
SETTING_MAY_START_AGENTS 🔒
agent:maystartagents: the person turned on “Agents may start agents” in Settings, so no agent’s start shows a card.
WORKER_OF_CONTENT 🔒
The leader a worker belongs to, and the content type that records it. They live in backend::agent_seat, which reads them without naming server/. The worker’s leader, {agent, id}, kept on the worker’s definition (agent content) as well as on its pane, so a worker reopened from My Agents, whose new pane has no agent:coached_by, is still a worker: it can’t spawn and still counts toward its leader’s limit. srv writes it; setagentcontent refuses it from a client, and a fork of a worker doesn’t inherit it.

Statics§

LEADER_LOCKS 🔒
One spawn at a time per leader, from counting its workers to opening the new one, including the wait for the user. Like agent_open’s locks, it serializes only this process’s calls.

Functions§

account_blocks 🔒
The accounts that can’t take a worker now, and why: signed out (its status), or a pane on it whose last run ended on the plan’s usage limit or a refused sign-in (agent:last_failure, which its next clean turn clears). A usage limit counts until its reset, when one is known, even with the pane still open (SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §6.3).
account_blocks_at 🔒
account_blocks at now_ms.
account_for_job 🔒
The account and provider the next worker of a spawn job led by leader_uid would run on (choose_account), without opening it: what the spending caps weigh before the run starts (jobs spec §5.3). None when the leader isn’t running or no account can take a worker.
account_label 🔒
account_label_in 🔒
account_label with the number that tells it from the other accounts of its provider and email (all).
account_matches 🔒
wanted names a: its id, name, display name or email, ignoring case.
agents_may_start_agents 🔒
announce_start 🔒
Tell the person in the leader’s pane that it starts agents, and whether it may go ahead (docs/specs/SPEC_AGENT_SPAWN_NOTICE_IN_THE_PANE_2026_11_08.md). Nothing waits for a click:
choose_account 🔒
The account to run the worker on (§3.5): the one asked for, else the leader’s, else, when the leader’s can’t run (account_blocks), the first of the user’s other accounts for the provider that can, with a note saying why. Refused when the one asked for can’t run, or none can.
client_may_write_content 🔒
setagentcontent’s check (a client’s write): which agent a worker reports to, and which agent made another, are srv’s to write: clearing the first would let a worker spawn and free its leader’s place, and writing the second would let an agent delete one it did not make.
coached_by_id 🔒
consent 🔒
What the person is shown about one worker.
consent_message 🔒
The facts of a start, from srv’s record: its model, placement, who pays.
creator_of 🔒
The agent that made def_id: the one that created it, or the leader it is a worker of.
discard_worker 🔒
Remove a worker whose open failed: the pane the open may have made in tab_id before failing (closed as any pane is, delete_block), then its definition, as the deleteagent RPC deletes one.
handle_agent_spawn 🔒
handle_agent_workers 🔒
POST /api/v1/agent/workers: the caller’s own open workers. A caller that isn’t a leader gets an empty list.
launch 🔒
Build the worker from the leader’s definition and open it. A worker that doesn’t open is removed again, with any pane the open made before it failed: the user didn’t get a worker, so there is no definition of one in My Agents and no marked pane taking up one of the leader’s places.
leader_at 🔒
The leader whose pane is block_id, if it may spawn: an agent of any kind, host or container, not a worker. A container leader’s worker is a container worker (copy_definition keeps the type and the image).
leader_lock 🔒
leader_of 🔒
The verified caller, if it may spawn: an agent’s own pane, host or container, not a worker’s.
live_workers_of 🔒
How many open panes leader_def_id coaches: workers in some tab, or parked (still running).
next_worker_name 🔒
“ worker N”, the first N no agent is named.
one_line 🔒
s on one line, at most max characters.
open_worker 🔒
Remember the worker’s runtime, then open it in tab_id (right of the leader’s pane when that pane is in the tab), marked as the leader’s worker from the moment its block exists.
refuse 🔒
requester_here 🔒
Whether the requester is still there to start things for: its pane exists and its agent was not stopped since (an explicit stop keeps the pane). A parked agent’s pane exists and it still runs.
runtime_of 🔒
native / container for a definition’s agent_type, and its image when it has one.
spawn_beside_leader 🔒
spawn_for_drone 🔒
Open a worker for a drone’s Spawn block: the path of spawn_for_job, but the person is told first, by the card with a countdown that goes ahead on its own, unless their settings already allow agents to start agents. A drone run isn’t known to be one the operator started, so the block doesn’t count as their approval.
spawn_for_job 🔒
Open a worker for the job whose leader is leader_uid, from its running pane: the same path as an agent’s spawn, without asking the user, since the operator created the job. MAX_LIVE_WORKERS and “workers can’t spawn” apply.
spawn_with 🔒
Open a worker for leader as req asks. operator_approved: the operator made the decision beforehand (a job they created), so the user isn’t asked; the limits and the leader’s checks still apply.
spawn_worker 🔒
worker_of 🔒
The leader a worker belongs to, and the content type that records it. They live in backend::agent_seat, which reads them without naming server/. The leader definition def_id is a worker of, if any.
worker_runtime 🔒
workers_of 🔒
leader_def_id’s workers open in a tab or parked: panes marked as its (on the pane or on their definition), with their state and last report.
written_only_by_srv 🔒
Content only srv writes, and that a fork of the agent does not take along.