synth_ai.research.swarms
Alpha
client.research.swarms — launch and lifecycle for Managed Swarms.
A Managed Swarm is one bounded multi-agent execution under the Managed
Research (SMR) umbrella. Swarms launch directly against a project, or are
composed by Managed Factories through Efforts. The wire protocol still uses
run/run_id; this module is the public noun layer over it.
Functions
swarm_state_is_terminal
RunState (the same terminal-state source the low-level
wait/contract path is projected from) instead of hand-authoring a string
set. Unknown states are non-terminal.
classify_event_kind
kind into a coarse forward-compatible category.
Returns one of "tool", "message", "turn", "usage",
"status", or "other". Unknown kinds always classify as "other"
so new backend event kinds never break consumers.
Classes
SwarmPreflightBlockedError
Raised when launch_and_wait preflight is not clear to trigger.
Carries the structured blockers list and the full preflight payload so
callers can act on the class of denial rather than a bare message.
SwarmLaunchBackpressureError
Raised when swarm launch exhausts its bounded backpressure retries.
SwarmResult
Typed outcome of :meth:ResearchSwarmsAPI.launch_and_wait.
Methods:
is_terminal
SwarmRetryResult
Typed outcome of :meth:ResearchSwarmHandle.retry.
Provenance (which swarm this retry came from and why) lives here
client-side; the launch wire has no metadata field to carry it.
ResearchSwarmHandle
Swarm-scoped readouts and lifecycle (public hero session type).
A Managed Swarm is one bounded multi-agent execution. Prefer
ResearchSwarmSession in type hints — RunHandle is not part of the
public hero surface.
Methods:
swarm_id
run_id).
wait_until_terminal
wait).
Args:
timeout: Max seconds to wait; the operator owns the wall clock.poll_interval: Seconds between status polls.
- class:
ResearchSwarmpublic state model.
is_terminal
terminal flag — the same authority
the low-level wait loop polls.
retry
mode:"fresh"re-launches the project’s configured swarm;"from_checkpoint"branches from an existing checkpoint.reason: Optional operator reason, recorded client-side on the result (and on the branch request for checkpoint retries).checkpoint_id: Required whenmode="from_checkpoint".
- class:
SwarmRetryResultwith the new swarm id and handle.
ValueError: If the source swarm is not terminal, or the mode / checkpoint arguments are inconsistent.
progress_snapshot
snapshots.get(detail=...).
full_progress
snapshots.get(detail='full')).
stream_transcript
work_product_content
download_workspace_archive
workspace.download.
list_artifacts
artifacts.list.
ResearchSwarmsAPI
Public Managed Swarm methods (alpha must-have).
Methods:
runbook_presets
swarms.create.
check_preflight
projects.setup.prepare to surface blockers (missing repo,
secrets, budget caps) without creating a swarm record.
Returns:
- Preflight payload with
allowedflag and structured denials.
launch_and_wait
check_preflight first and fails immediately with a typed
:class:SwarmPreflightBlockedError when not clear to trigger. Launch
is wrapped in a bounded backpressure retry (HTTP 502/503/504 and
concurrent-run-limit backpressure, max 5 attempts, capped
backoff); other errors raise immediately. Then blocks until terminal
and assembles a typed :class:SwarmResult.
Args:
project_id: Owning project id.objective: Primary operator message (objective launch path). When omitted, the project’s configured swarm is triggered.timeout: REQUIRED max seconds to wait for terminal state — the operator owns the wall clock; there is no wait-forever default.poll_interval: Seconds between status polls.raise_if_failed: Raise when the swarm ends failed/blocked.**launch_kwargs: Any launch-request field the backend accepts (execution_target,local_execution,limit, …).
- class:
SwarmResultwith final state, usage, cost, work products, - and a live handle for further readouts.
launch_preflight
check_preflight.
create
objective is provided, returns a :class:ResearchSwarmHandle.
Objective-less calls retain their historical raw response. Use
:meth:create_configured for a typed configured-swarm launch.
Args:
project_id: Owning project id.objective: Primary operator message for the swarm (preferred launch path).
- A typed handle for objective launches, otherwise the legacy raw payload.
create_configured
start
create).
launch
create with a required objective.
trigger
start_run
create).
get
(project_id, swarm_id), (swarm_id,) when project is implied,
or keyword forms. Prefer nested readouts on the returned handle:
handle.usage.get(), handle.snapshots.get(), handle.transcript.get().
open
get).
state
public_state
list
list_active
wait
timeout: Max seconds to wait (Nonewaits indefinitely).poll_interval: Seconds between status polls.raise_if_failed: Raise when the swarm ends in a failed state.
- Final
ResearchSwarmpublic state model.
transcript
handle.transcript.get).
stream_events
handle.events.stream).
resource_limits
progress_toward_resource_limits
stop
pause
resume
results
logs
logs_page
SyncPagewithitems,next_cursor, andhas_morefor- cursor-based iteration without hand-parsing wire payloads.