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 asmember()records with a name, role, count, limits and sandbox. A member builder, an@agentfunction 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_memoryis a board of files with notices andswarm_wait. 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(), and notices of other members' changes between turns from swarm_on_continue(). Call both 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() or swarm_on_continue() 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_on_continue, swarm_tools
@agent
def worker() -> Agent:
return react(tools=[bash(), swarm_tools()], on_continue=swarm_on_continue())
solver = swarm(members=member(worker, name="w", count=3), channels=[shared_memory()])
At each turn boundary where other agents have changed files since its last notice, a member gets one notice, such as:
[Swarm notice] 1 shared memory file changed since you last viewed it (f-1 new; by w-1). View one with shared_memory(command="view", path="f-1"), or list them with path="/shared_memory".
The swarm logs every write, view, notice 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. The swarm keeps three records in the sample store:
inspect_swarm:result: each member's state and status, and which member's output is the answer. Only the swarm writes it.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:
- https://meridianlabs-ai.github.io/inspect_swarm/llms.txt: an index of the pages, with a line on what each covers.
- https://meridianlabs-ai.github.io/inspect_swarm/llms-guide.txt: the user guide as one Markdown file.
- https://meridianlabs-ai.github.io/inspect_swarm/llms-full.txt: the user guide and the API reference as one Markdown file.
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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| inspect_swarm-0.1.0.tar.gz | 88.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| inspect_swarm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 189.4 kB
Release files / inspect_swarm-0.1.0.tar.gz
| Download URL | inspect_swarm-0.1.0.tar.gz |
|---|---|
| Size | 88.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78e75588583f6a09716973589fe1dbb9bebacf0f2b6a0cd6244ae0e31d7b9048
|
|
BLAKE2b-256 checksum How to use checksums |
dd7a47f9fb7dd58b29715b2985b5398c53be6cc09b3321b73ada98ab273b02f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 23, 2026.
Transparency logRelease files / inspect_swarm-0.1.0-py3-none-any.whl
| Download URL | inspect_swarm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 101.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4600ae6709673cd33048b50728a626376d5f943df9e79e2918d6b330b99299d
|
|
BLAKE2b-256 checksum How to use checksums |
b60fb86e986fb631688286690571dfd2d85e1ed76b49dadd74809b7e061dd12b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 23, 2026.
Transparency logSecurity for inspect-swarm 0.1.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for inspect_swarm-0.1.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 Oct 23, 2026.
Transparency logA 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.