Skip to main content

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.

SwarmCore flow demo

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_context at 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

swarmcore-0.2.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmcore-0.2.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

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

Hashes for swarmcore-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0436a04c581051d8aa6c7df783fcf6a4acd9218bc9360ac34e2aecd4a06074ca
MD5 7ffec5fb4427042008eea84daba8d8e8
BLAKE2b-256 331708768da05343eb65abb09096673d27ff09ec756eb69dd8e0e38aab25d284

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmcore-0.2.0.tar.gz:

Publisher: python-publish.yml on MatchaOnMuffins/swarmcore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for swarmcore-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 106fe8bcc4f7cc474587ecf2f2cc072abe1863d7cbe1406e812a65e6a83e8bc2
MD5 82ab33ca1b3d88f76f2503b589a9d24a
BLAKE2b-256 4269949e610b6c56c7cbba7fd8d330c727602ceea198fcdbd99a0377bb557b44

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarmcore-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on MatchaOnMuffins/swarmcore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page