API

AgentSwarm

Operations

Every route this entity exposes. Each route links to its own reference on this page.

Method Route SDK operation Returns
POST /api/v1/agent/swarms/{id}/cancel create Agent swarm canceled (PRD 146 FR30)
POST /api/v1/agent/swarms create Success
GET /api/v1/agent/swarms list One page of agent swarms in the organization
GET /api/v1/agent/swarms/{id} load Agent swarm with recent tasks
GET /api/v1/agent/swarms/{id}/live load One page response for the swarm live view
GET /api/v1/agent/swarms/{id}/policy load The swarm's effective policy, budget and pinned environment
PATCH /api/v1/agent/swarms/{id}/policy update The swarm's effective policy after the edit

Examples

One example per SDK, generated from the API model. The argument names are the parameters and fields of this entity, and the values are placeholders. The examples are not compiled or executed.

Golang

Construct client as shown in the Golang setup, then call the operations:

agent_swarms, err := client.AgentSwarm(nil).List(map[string]any{"org": "example"}, nil)
if err != nil {
    panic(err)
}
fmt.Println(agent_swarms)
agent_swarm, err := client.AgentSwarm(nil).Load(map[string]any{"id": "example_id"}, nil)
if err != nil {
    panic(err)
}
fmt.Println(agent_swarm)
created, err := client.AgentSwarm(nil).Create(map[string]any{"organization_slug": "example"}, nil)
if err != nil {
    panic(err)
}
fmt.Println(created)

Lua

Construct client as shown in the Lua setup, then call the operations:

local agent_swarms, err = client:AgentSwarm():list({ org = "example" })
local agent_swarm, err = client:AgentSwarm():load({ id = "example_id" })
local created, err = client:AgentSwarm():create({ organization_slug = "example" })

PHP

Construct client as shown in the PHP setup, then call the operations:

$agent_swarms = $client->AgentSwarm()->list(["org" => "example"]);
$agent_swarm = $client->AgentSwarm()->load(["id" => "example_id"]);
$created = $client->AgentSwarm()->create(["organization_slug" => "example"]);

Python

Construct client as shown in the Python setup, then call the operations:

agent_swarms = client.AgentSwarm().list({"org": "example"})
agent_swarm = client.AgentSwarm().load({"id": "example_id"})
created = client.AgentSwarm().create({ "organization_slug": "example" })

Ruby

Construct client as shown in the Ruby setup, then call the operations:

agent_swarms = client.AgentSwarm.list({ "org" => "example" })
agent_swarm = client.AgentSwarm.load({ "id" => "example_id" })
created = client.AgentSwarm.create({ "organization_slug" => "example" })

TypeScript

Construct client as shown in the TypeScript setup, then call the operations:

const agent_swarms = await client.AgentSwarm().list({ org: "example" })
const agent_swarm = await client.AgentSwarm().load({ id: "example_id" })
const created = await client.AgentSwarm().create({ organization_slug: "example" })

Fields

Field Type Required Description
base_bookmark one,string,null Yes An existing bookmark to start from and land on; the plain form of target.kind = bookmark.
base_ref one,string,null Yes Base Ref
base_revision one,string,null Yes 64-hex commit id; skips the head lookup
budget object Yes Budget
canceled_at one,string,null Yes Canceled At
canceled_count integer Yes Canceled Count
concurrency_key one,string,null Yes Concurrency Key
created_at string Yes Created At
created_at_label one,string,null Yes Created At Label
creator_user_id one,string,null Yes Creator User Id
deadline_at one,string,null Yes Deadline At
display_id integer Yes Display Id
done_count integer Yes Done Count
environment object Yes Environment
failed_count integer Yes Failed Count
finished_at one,string,null Yes Finished At
finished_at_label one,string,null Yes Finished At Label
github object Yes Github
goal one,string,null Yes Goal
id string Yes Id
model one,string,null Yes Model
model_provider one,string,null Yes Model Provider
number integer Yes Number
organization_id string Yes Organization Id
organization_slug one,string,null Yes Organization Slug
outcome one,string,null Yes Outcome
phase one,string,null Yes Phase
policy object Yes Every key is optional and defaults to AgentSwarm::POLICY_DEFAULTS.
queued_at one,string,null Yes Queued At
queued_at_label one,string,null Yes Queued At Label
repository string No Repository slug inside the organization
repository_id one,string,null Yes Repository Id
repository_slug one,string,null Yes Repository Slug
reserved object Yes Reserved
scheduler_generation integer Yes Scheduler Generation
skipped_count integer Yes Skipped Count
slug string Yes Slug
started_at one,string,null Yes Started At
started_at_label one,string,null Yes Started At Label
status string Yes Status
summary object Yes Summary
target object No Where the swarm lands.
task_count integer Yes Task Count
task_template_json one,string,null Yes Task Template Json
tasks array Yes Tasks
updated_at string Yes Updated At
updated_at_label one,string,null Yes Updated At Label
usage object Yes Usage

create

POST /api/v1/agent/swarms/{id}/cancel

Operation ID: cancel_api_v1_swarm.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
id path string Yes

Request body

application/json

Property Type Required Description
reason string No

Responses

200: Agent swarm canceled (PRD 146 FR30)

application/json

Property Type Required Description
swarm object and object Yes
401: Unauthorized
403: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
404: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
409: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
422: Unprocessable entity
502: Bad gateway

POST /api/v1/agent/swarms

Operation ID: post_api_v1_agent_swarms.

Authentication: bearer token (bearerAuth).

Request body

application/json

Property Type Required Description
base_bookmark string No An existing bookmark to start from and land on; the plain form of target.kind = bookmark.
base_ref string No
base_revision string No 64-hex commit id; skips the head lookup
budget object No
budget.build_reserve_usd number No
budget.cleanup_reserve_usd number No
budget.max_build_seconds integer No
budget.max_usd number No
budget.max_wall_clock_seconds integer No
concurrency_key string No
environment object No
goal string No
model string No
model_provider string No
organization_slug string Yes
policy object No Every key is optional and defaults to AgentSwarm::POLICY_DEFAULTS.
policy.deploy string No
policy.environment_profile string No
policy.landing string No
policy.max_depth integer No
policy.max_parallel_workers integer No
policy.max_root_iterations integer No
policy.max_runs integer No
policy.max_subplanner_iterations integer No
policy.max_task_attempts integer No
policy.max_tasks integer No
policy.models object No Per-role model overrides; roles left out keep the platform defaults.
policy.plan_only boolean No
policy.platform enum: composal, github No
policy.reserve_org_slot boolean No
policy.restack_attempts integer No
policy.submit_on_failure boolean No
policy.swarm_deadline_seconds integer No
policy.task_deadline_seconds integer No
queued_at string (date-time) No
repository string No Repository slug inside the organization
slug string No
target object No Where the swarm lands. trunk is the repository's default branch; bookmark an existing bookmark named by name; new_bookmark a bookmark named by name that the launch creates at trunk's head. Every worker starts from the target's head and every Change is opened against it; its merge queue is found or created on the first landing.
target.kind enum: trunk, bookmark, new_bookmark Yes
target.name string No
task_template_json string No
tasks array of object No
tasks[].acceptance_commands array of object No
tasks[].acceptance_commands[].command string Yes
tasks[].acceptance_commands[].timeout_seconds integer No
tasks[].depends_on array of integer No
tasks[].environment_profile string No
tasks[].harness enum: roder, codex No
tasks[].owned_paths array of string No
tasks[].prompt string Yes
tasks[].repo_url string (uri) No
tasks[].role enum: worker, subplanner No
tasks[].stack_after integer No
tasks[].title string No

Responses

200: Success

application/json

The response is object.

201: Agent swarm created

application/json

Property Type Required Description
swarm object and object Yes
400: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
401: Unauthorized
403: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
404: Not found
422: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
502: Bad gateway

list

GET /api/v1/agent/swarms

Operation ID: api_v1_swarms.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
org query string Yes Organization slug. Swarms belong to one organization and the list is read under one.
page query integer No 1-based page number. The list is paginated because counting tasks for every swarm is not free.
per_page query integer No Swarms per page, 1 to 100. Defaults to 25.

Responses

200: One page of agent swarms in the organization

application/json

Property Type Required Description
has_more boolean Yes
page integer Yes
per_page integer Yes
swarms array of object Yes
swarms[].base_bookmark string Yes
swarms[].base_ref string Yes
swarms[].base_revision string Yes
swarms[].budget object Yes
swarms[].canceled_at string (date-time) Yes
swarms[].canceled_count integer Yes
swarms[].concurrency_key string Yes
swarms[].created_at string (date-time) Yes
swarms[].created_at_label string Yes
swarms[].creator_user_id string Yes
swarms[].deadline_at string (date-time) Yes
swarms[].display_id integer Yes
swarms[].done_count integer Yes
swarms[].environment object Yes
swarms[].failed_count integer Yes
swarms[].finished_at string (date-time) Yes
swarms[].finished_at_label string Yes
swarms[].github object Yes
swarms[].github.commits integer Yes
swarms[].github.platform enum: composal, github Yes
swarms[].github.prs_merged integer Yes
swarms[].github.prs_opened integer Yes
swarms[].goal string Yes
swarms[].id string Yes
swarms[].model string Yes
swarms[].model_provider string Yes
swarms[].number integer Yes
swarms[].organization_id string Yes
swarms[].organization_slug string Yes
swarms[].outcome enum: succeeded, partially_succeeded, failed, canceled, budget_exhausted Yes
swarms[].phase enum: planning, executing, landing, releasing, terminal Yes
swarms[].policy object Yes
swarms[].queued_at string (date-time) Yes
swarms[].queued_at_label string Yes
swarms[].repository_id string Yes
swarms[].repository_slug string Yes
swarms[].reserved object Yes
swarms[].scheduler_generation integer Yes
swarms[].skipped_count integer Yes
swarms[].slug string Yes
swarms[].started_at string (date-time) Yes
swarms[].started_at_label string Yes
swarms[].status enum: queued, running, succeeded, failed, canceled Yes
swarms[].summary object Yes
swarms[].task_count integer Yes
swarms[].task_template_json string Yes
swarms[].updated_at string (date-time) Yes
swarms[].updated_at_label string Yes
swarms[].usage object Yes
total integer Yes
401: Unauthorized
403: Forbidden
404: Not found
422: Unprocessable entity
502: Bad gateway

load

GET /api/v1/agent/swarms/{id}

Operation ID: api_v1_swarm.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
id path string Yes

Responses

200: Agent swarm with recent tasks

application/json

Property Type Required Description
swarm object and object Yes
401: Unauthorized
403: Forbidden
404: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
422: Unprocessable entity
502: Bad gateway

GET /api/v1/agent/swarms/{id}/live

Operation ID: get_api_v1_agent_swarms_id_live.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
id path string Yes

Responses

200: One page response for the swarm live view

application/json

Property Type Required Description
activity array of object Yes
activity[].at_ms integer Yes
activity[].attempt_id string Yes
activity[].duration_ms integer Yes
activity[].exit_code integer Yes
activity[].kind enum: shell, shell_exit, read_file, write_file, commit, export, ... Yes
activity[].path string Yes
activity[].payload object Yes
activity[].seq integer Yes
activity[].summary string Yes
activity[].task_id string Yes
activity[].ts string (date-time) Yes
activity_retained integer Yes
events array of object Yes
events[].at_ms integer Yes
events[].attempt_id string Yes
events[].id integer Yes
events[].kind string Yes
events[].landing_entry object or null Yes
events[].payload object Yes
events[].reason string Yes
events[].task_id string Yes
events[].ts string (date-time) Yes
landing object Yes
landing.entries array of object Yes
landing.entries[].at string (date-time) Yes
landing.entries[].change_numbers array of integer Yes
landing.entries[].entry_id string Yes
landing.entries[].landed_commit string Yes The first twelve characters of the commit the closure landed as.
landing.entries[].pull_requests array of object Yes
landing.entries[].pull_requests[].number integer Yes
landing.entries[].pull_requests[].state enum: opened, open, closed, merged, failed Yes
landing.entries[].pull_requests[].url string Yes
landing.entries[].queue_position integer Yes The entry's place in the merge queue while it is still in it.
landing.entries[].short_label string Yes
landing.entries[].state string Yes held | released | requested | validating | ready | restack | landed | failed | revoked
landing.entries[].task_id string Yes
landing.master_tip string Yes
server_time string (date-time) Yes
swarm object Yes
swarm.active_workers integer Yes
swarm.base_bookmark string Yes
swarm.budget object Yes
swarm.budget.gb_seconds_used integer Yes
swarm.budget.tokens_cap integer Yes
swarm.budget.tokens_used integer Yes
swarm.budget.usd_cap_nanodollars integer Yes
swarm.budget.usd_spent_nanodollars integer Yes
swarm.budget.vcpu_seconds_cap integer Yes
swarm.budget.vcpu_seconds_used integer Yes
swarm.budget.wall_clock_cap_seconds integer Yes
swarm.finished_at string (date-time) Yes
swarm.github object Yes
swarm.github.commits integer Yes
swarm.github.prs_merged integer Yes
swarm.github.prs_opened integer Yes
swarm.goal string Yes
swarm.id string Yes
swarm.launched_at string (date-time) Yes
swarm.machine object Yes
swarm.machine.cpu_millicores integer Yes
swarm.machine.memory_mb integer Yes
swarm.master_tip string Yes
swarm.number integer Yes
swarm.organization_slug string Yes
swarm.outcome enum: succeeded, partially_succeeded, failed, canceled, budget_exhausted Yes
swarm.phase enum: planning, executing, landing, releasing, terminal Yes
swarm.platform enum: composal, github Yes
swarm.repository_slug string Yes
swarm.slug string Yes
swarm.stacks_landed integer Yes
swarm.started_at string (date-time) Yes
swarm.status enum: queued, running, succeeded, failed, canceled Yes
swarm.tasks_done integer Yes
swarm.tasks_total integer Yes
tasks array of object Yes
tasks[].blocked_reason string Yes
tasks[].change_numbers array of integer Yes
tasks[].current_attempt_id string Yes
tasks[].depth integer Yes
tasks[].failure_code string Yes
tasks[].finished_at string (date-time) Yes
tasks[].id string Yes
tasks[].iteration integer Yes
tasks[].landing_state string Yes
tasks[].number integer Yes
tasks[].parent_task_id string Yes
tasks[].plan_reason string Yes
tasks[].plan_summary string Yes
tasks[].position integer Yes
tasks[].pull_requests array of object Yes
tasks[].pull_requests[].number integer Yes
tasks[].pull_requests[].state enum: opened, open, closed, merged, failed Yes
tasks[].pull_requests[].url string Yes
tasks[].role enum: planner, subplanner, worker, restack, release_watch Yes
tasks[].short_label string Yes
tasks[].started_at string (date-time) Yes
tasks[].status enum: queued, blocked, running, succeeded, failed, canceled, ... Yes
tasks[].title string Yes
tasks[].updated_at string (date-time) Yes
401: Unauthorized
403: Forbidden
404: Swarm not visible to the current user

application/json

Property Type Required Description
error string Yes
422: Unprocessable entity
502: Bad gateway

GET /api/v1/agent/swarms/{id}/policy

Operation ID: policy_api_v1_swarm.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
id path string Yes

Responses

200: The swarm's effective policy, budget and pinned environment

application/json

Property Type Required Description
budget object Yes
environment object Yes
policy object Yes
scheduler_generation integer Yes
401: Unauthorized
403: Forbidden
404: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
422: Unprocessable entity
502: Bad gateway

update

PATCH /api/v1/agent/swarms/{id}/policy

Operation ID: patch_api_v1_agent_swarms_id_policy.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
id path string Yes

Request body

application/json

Property Type Required Description
policy object Yes

Responses

200: The swarm's effective policy after the edit

application/json

Property Type Required Description
budget object Yes
environment object Yes
policy object Yes
scheduler_generation integer Yes
400: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
401: Unauthorized
403: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
404: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
409: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
422: Invalid agent swarm request

application/json

Property Type Required Description
details array of string No
error string Yes
502: Bad gateway