Skip to main content

Inspect Swarm

Experimental. Everything in Inspect Swarm is experimental and may change in any release without notice, including swarm(), member(), Budget, the built-in controller and channel names, and the record and evidence formats. No support is guaranteed.

Inspect Swarm runs a swarm of agents on one sample of an Inspect task. A swarm is an Inspect agent, so it replaces the task's solver and the task's scorer scores the swarm's answer.

Documentation: https://meridianlabs-ai.github.io/inspect_swarm. Runnable examples are in examples/.

Installation

Install it from PyPI:

pip install inspect_swarm

or, in a uv project:

uv add inspect_swarm

To install the latest development version from GitHub:

pip install git+https://github.com/meridianlabs-ai/inspect_swarm

or, in a uv project:

uv add "inspect_swarm @ git+https://github.com/meridianlabs-ai/inspect_swarm"

It needs inspect_ai 0.3.283 or later and Python 3.11 or later.

Run a swarm on an existing task

Pass swarm() as the solver. From Python:

from inspect_ai import eval
from inspect_ai.agent import react

from inspect_swarm import member, swarm

from my_tasks import my_task

eval(
    my_task(),
    solver=swarm(members=member(react, count=4)),
    model="anthropic/claude-sonnet-4-5",
)

From the command line:

inspect eval my_tasks.py --solver inspect_swarm/swarm -S 'members={factory: react, count: 4}'

Each sample runs four react() members, react-1 to react-4, at the same time. Each starts with the sample's input and a short preamble: its name, the number of members, and how to share files. By default the swarm stops at the first submission and uses it as its answer. It stops the remaining members. To let every member run to its end, use leaderless(stop_on_submission=False). The task's scorer scores it as it would score a single agent.

--solver and eval(solver=...) replace the task's whole solver, including any system message or tools it set up, so give the members their tools and prompt. Members use the eval's model unless they are given one. The task's setup solver still runs first.

What a swarm has

  • Members: agents registered with @agent, given as member() records with a name, role, count, limits and sandbox. A member builder, an @agent function that builds the member's agent, is where it gets the swarm's tools. See Members.
  • A controller: which members start and when the swarm stops. The default, leaderless, starts every member and stops at the first submission. See Controllers, which also covers writing one.
  • Channels: how members share information. filesystem, the default, describes a shared directory in the sample's sandbox. shared_memory is a board of files with swarm_wait. messages lets members send each other messages. See Channels.
  • A budget: caps on cost, tokens and time, taken from the sample's limits by default, shared or split between members. See Budgets.
  • Sandboxes: members share the sample's sandbox, or each works in its own. See Sandboxes.

The shared-memory channel

shared_memory() gives the swarm one board of files that every member reads and writes with a shared_memory tool, and a swarm_wait tool to wait for other members instead of polling. Members get the tools from swarm_tools(). Call it inside a member builder registered with @agent, and pass the builder to member() without calling it. The log records a builder by name and arguments, so the swarm can be rebuilt from the log; it cannot rebuild swarm_tools() passed in args or in an agent you built.

from inspect_ai.agent import Agent, agent, react
from inspect_ai.tool import bash

from inspect_swarm import member, shared_memory, swarm, swarm_tools


@agent
def worker() -> Agent:
    return react(tools=[bash(), swarm_tools()])


solver = swarm(members=member(worker, name="w", count=3), channels=[shared_memory()])

Every shared_memory result ends with a status line that names the files other agents changed since the member last viewed them, such as:

Shared memory: 1 file changed since you last viewed it (f-1 new).

shared_memory(command="changes") returns that line alone. The swarm adds no messages to a member's conversation.

The swarm logs every write, view and wait. See Shared Memory for the tool's commands, waiting, subagents, limits, monitoring with Inspect Sentinel, and migrating from memory(instance=...).

Results

By default the swarm's answer is the first submission. leaderless(stop_on_submission=False, final="last") makes it the latest, and a controller of your own can choose it. The swarm's output is the chosen member's ModelOutput, unchanged. When the swarm ends, it writes its result record to the transcript: each member's state and status, and which member's output is the answer. Read it with swarm_result(). The swarm keeps two more records in the sample store:

  • inspect_swarm:ledger: the swarm's caps and each member's usage and cost.
  • inspect_swarm:metrics: tokens, cost and time, and counts of how each member acted, communicated and waited.

inspect_swarm.analysis adds the swarm's cost and ledger data to Inspect's samples_df(). See Scoring, Analysis and Restrictions.

For agents

The documentation is also published as Markdown for agents:

Development

See CONTRIBUTING.md. The documentation's source is in docs/; make docs builds it. The designs behind the swarm are in design/.

Metadata

Release files for inspect-swarm 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inspect-swarm 0.3.0
File Size Uploaded Provenance Actions
inspect_swarm-0.3.0.tar.gz 99.9 kB With provenance Details for inspect_swarm-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inspect-swarm 0.3.0
File Interpreter ABI Platform Actions
inspect_swarm-0.3.0-py3-none-any.whl Python 3 none any Details for inspect_swarm-0.3.0-py3-none-any.whl

Total release size: 215.3 kB

Release files / inspect_swarm-0.3.0.tar.gz

Download URL inspect_swarm-0.3.0.tar.gz
Size 99.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a6b079b04e870a93d943abfb53d6fec34fb91c0644d2bfa0b5ffd1b1b16fe28b
BLAKE2b-256 checksum
How to use checksums
11fb35fe570dc92aee5f40dd274a3e1c06fdf30f2a77819f03424f4278bbe336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / inspect_swarm-0.3.0-py3-none-any.whl

Download URL inspect_swarm-0.3.0-py3-none-any.whl
Size 115.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8fd1c2e2a1f5836bc73f7eec9a1671955093d67651daf88ac9bcb88377d4a45
BLAKE2b-256 checksum
How to use checksums
f518f795ef9102309853b3b3c783ab160c38b8e7cceff9efa54bfe663cb88f2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for inspect-swarm 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for inspect_swarm-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page