Coordinate AI agents in a workflow
Project description
SwarmCore
Scalable AI agent coordination. Compose agents into sequential and parallel flows with automatic context management that stays lean as the swarm grows.
pip install swarmcore
Quickstart
import asyncio
from swarmcore import Agent, Swarm
researcher = Agent(name="researcher", instructions="Research the topic.", model="anthropic/claude-sonnet-4-20250514")
writer = Agent(name="writer", instructions="Write a report from the research.", model="anthropic/claude-sonnet-4-20250514")
result = asyncio.run(Swarm(flow=researcher >> writer).run("AI agent trends in 2025"))
print(result.output)
The researcher runs first, its output goes into shared context, and the writer sees it automatically.
Tiered Context
Most multi-agent frameworks dump every prior agent's full output into the next prompt. That blows up at scale. SwarmCore keeps it tight:
- Immediately preceding step → full output
- Everything earlier → summaries only
- Need more? → agents call
expand_contextat runtime to pull any prior agent's full output
agent_1 >> agent_2 >> ... >> agent_10
agent_10 sees: agents 1-8 [SUMMARIES] + agent_9 [FULL]
(can expand any earlier agent on demand)
The tool and prompt hint are injected automatically. Agents produce summaries via <summary> tags in their output — if omitted, the full output is used instead.
Flows
>> for sequential, | for parallel:
planner >> writer # sequential
(researcher | critic) >> writer # parallel then sequential
planner >> (researcher | critic) >> writer # mixed
Or the functional API:
from swarmcore import chain, parallel
Swarm(flow=chain(planner, parallel(researcher, critic), writer))
Parallel agents share the same context snapshot — they don't see each other's outputs.
Tools
Plain Python functions:
def search_web(query: str) -> str:
"""Search the web for information."""
return results
agent = Agent(name="researcher", instructions="...", tools=[search_web])
Type hints and docstrings are converted to tool schemas automatically. Sync and async functions both work.
Models
Any LiteLLM-compatible model:
Agent(name="a", instructions="...", model="anthropic/claude-sonnet-4-20250514")
Agent(name="b", instructions="...", model="openai/gpt-4o")
Agent(name="c", instructions="...", model="ollama/llama3")
Agent(name="d", instructions="...", model="groq/llama-3.1-8b-instant")
API
Agent(name, instructions, model, tools=None)
| Param | Type | Default | Description |
|---|---|---|---|
name |
str |
required | Identifier used in context keys |
instructions |
str |
required | System prompt |
model |
str |
"anthropic/claude-sonnet-4-20250514" |
LiteLLM model string |
tools |
list[Callable] |
None |
Tool functions |
Swarm(flow)
| Param | Type | Description |
|---|---|---|
flow |
Flow |
Execution plan from operators or chain()/parallel() |
SwarmResult
| Field | Type | Description |
|---|---|---|
output |
str |
Final agent's output |
context |
dict[str, str] |
All outputs keyed by agent name |
history |
list[AgentResult] |
Ordered execution results |
AgentResult
| Field | Type | Description |
|---|---|---|
agent_name |
str |
Agent that produced this result |
output |
str |
Text output (summary tags stripped) |
summary |
str |
Summary from <summary> tags, or full output |
model |
str |
Model used |
duration_seconds |
float |
Wall-clock time |
token_usage |
TokenUsage |
Token counts |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmcore-0.2.0.tar.gz.
File metadata
- Download URL: swarmcore-0.2.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0436a04c581051d8aa6c7df783fcf6a4acd9218bc9360ac34e2aecd4a06074ca
|
|
| MD5 |
7ffec5fb4427042008eea84daba8d8e8
|
|
| BLAKE2b-256 |
331708768da05343eb65abb09096673d27ff09ec756eb69dd8e0e38aab25d284
|
Provenance
The following attestation bundles were made for swarmcore-0.2.0.tar.gz:
Publisher:
python-publish.yml on MatchaOnMuffins/swarmcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarmcore-0.2.0.tar.gz -
Subject digest:
0436a04c581051d8aa6c7df783fcf6a4acd9218bc9360ac34e2aecd4a06074ca - Sigstore transparency entry: 938524614
- Sigstore integration time:
-
Permalink:
MatchaOnMuffins/swarmcore@f46998072a749ca16df36930dfd19f3e95120251 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/MatchaOnMuffins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f46998072a749ca16df36930dfd19f3e95120251 -
Trigger Event:
release
-
Statement type:
File details
Details for the file swarmcore-0.2.0-py3-none-any.whl.
File metadata
- Download URL: swarmcore-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
106fe8bcc4f7cc474587ecf2f2cc072abe1863d7cbe1406e812a65e6a83e8bc2
|
|
| MD5 |
82ab33ca1b3d88f76f2503b589a9d24a
|
|
| BLAKE2b-256 |
4269949e610b6c56c7cbba7fd8d330c727602ceea198fcdbd99a0377bb557b44
|
Provenance
The following attestation bundles were made for swarmcore-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on MatchaOnMuffins/swarmcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarmcore-0.2.0-py3-none-any.whl -
Subject digest:
106fe8bcc4f7cc474587ecf2f2cc072abe1863d7cbe1406e812a65e6a83e8bc2 - Sigstore transparency entry: 938524620
- Sigstore integration time:
-
Permalink:
MatchaOnMuffins/swarmcore@f46998072a749ca16df36930dfd19f3e95120251 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/MatchaOnMuffins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f46998072a749ca16df36930dfd19f3e95120251 -
Trigger Event:
release
-
Statement type: