Headless framework for multi-agent chat runtime and evaluation.
Project description
SwarmForge
SwarmForge is a Python package for authoring, running, and evaluating multi-agent swarms. You define the swarm graph, provide the model-turn callback, and keep sessions, handoffs, tools, checkpoints, and evaluation artifacts under your control.
- Explicit graph-based multi-agent runtime
- Python tool execution with inferred JSON schema
- OpenRouter, Gemini, and other OpenAI-compatible provider support
- FastAPI transport for stateless and session-backed HTTP flows
- Evaluation helpers for graph snapshots, scenario seeds, and artifact scoring
Install
Python 3.11+ is required.
pip install swarmforge
If you want the FastAPI transport too:
pip install "swarmforge[api]"
Quick Start
The shortest path is a single-node swarm with a stubbed model callback:
import asyncio
import json
from swarmforge.swarm import (
AgentTurnResult,
InMemorySessionStore,
SwarmDefinition,
SwarmNode,
SwarmSession,
process_swarm_stream,
)
class ExampleTurnRunner:
async def run_turn(self, *, agent_node, contents, config):
del agent_node, contents, config
return AgentTurnResult(response_text="Here is a direct answer from SwarmForge.")
swarm = SwarmDefinition(
id="assistant",
name="Assistant Swarm",
nodes=[
SwarmNode(
id="assistant",
node_key="assistant",
name="Assistant",
intent="Handle general requests",
system_prompt="You are a concise assistant.",
capabilities=["Answer questions"],
is_entry_node=True,
)
],
)
async def main():
session = SwarmSession(id="session-1", swarm=swarm)
store = InMemorySessionStore()
async for event in process_swarm_stream(
session,
"Give me a concise summary.",
store=store,
turn_runner=ExampleTurnRunner(),
):
print(json.dumps(event, indent=2))
if __name__ == "__main__":
asyncio.run(main())
When you are ready to add routing, continue with the multi-agent flow in the docs.
Package Surfaces
swarmforge.swarmRuntime models, session state, orchestration, tool execution, and stores.swarmforge.authoringPrompt templates, payload validation, and graph compilation helpers.swarmforge.evaluationGraph snapshots, scenario generation, feasibility checks, and artifact scoring.swarmforge.apiFastAPI application factory built on the same runtime primitives.
Providers
SwarmForge ships with an OpenAI-compatible provider wrapper. OpenRouter is the default path, and Gemini is built in as an alternative mode.
OpenRouter setup:
export OPENROUTER_API_KEY=sk-or-...
export OPENROUTER_SITE_URL=https://your-app.example
export OPENROUTER_APP_NAME="Your App Name"
Gemini setup:
export GEMINI_API_KEY=...
Minimal client setup:
from swarmforge.evaluation.provider import ModelConfig, OpenAIClientWrapper
client = OpenAIClientWrapper(
ModelConfig(
provider="openrouter",
model="openrouter/auto",
)
)
FastAPI Transport
You can expose the runtime over HTTP without changing your swarm definitions:
pip install "swarmforge[api]"
uvicorn swarmforge.api.fastapi:create_fastapi_app --factory --reload
That app exposes both stateless run endpoints and session-backed endpoints with SSE streaming.
Documentation
- Getting Started
- Create Your First Agent
- Create Your First Multi-Agent Swarm
- Authoring
- Orchestration
- Providers
- API
- Evaluation
- Examples
Source Examples
The repository includes end-to-end example scripts under examples/. Those scripts are useful when you want runnable reference flows for authoring, orchestration, evaluation, provider integration, or FastAPI transport.
Contributing
Core modification, docs development, demo UI work, and PyPI release steps are documented in CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
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 swarmforge-0.3.0.tar.gz.
File metadata
- Download URL: swarmforge-0.3.0.tar.gz
- Upload date:
- Size: 58.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35c587e6b9ce675ec6c4a247935b7fc990d65f0f293353fad565e4a738a3295d
|
|
| MD5 |
c9e86a41210e4a0203538b9e95d40a2d
|
|
| BLAKE2b-256 |
92943b06c1f9f7b7499ddfee3bfa182dd70e905b33d98346b1bf84990debbff7
|
Provenance
The following attestation bundles were made for swarmforge-0.3.0.tar.gz:
Publisher:
release.yml on Rvey/swarm-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarmforge-0.3.0.tar.gz -
Subject digest:
35c587e6b9ce675ec6c4a247935b7fc990d65f0f293353fad565e4a738a3295d - Sigstore transparency entry: 1266956523
- Sigstore integration time:
-
Permalink:
Rvey/swarm-forge@40d1470275b1ef9ab32261d1bc05664584ed162a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Rvey
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@40d1470275b1ef9ab32261d1bc05664584ed162a -
Trigger Event:
push
-
Statement type:
File details
Details for the file swarmforge-0.3.0-py3-none-any.whl.
File metadata
- Download URL: swarmforge-0.3.0-py3-none-any.whl
- Upload date:
- Size: 53.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8da77f549de05b9fb82c3dd1cac0252ca5c23d89ea6e4e64316ffbd7a9328e8
|
|
| MD5 |
6b25e2f1b9c6e51ab171bd589add7cea
|
|
| BLAKE2b-256 |
24da64b6ef200c149ce491fda2effc144c9552d2c8b6f8d47bb6634207ec8597
|
Provenance
The following attestation bundles were made for swarmforge-0.3.0-py3-none-any.whl:
Publisher:
release.yml on Rvey/swarm-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarmforge-0.3.0-py3-none-any.whl -
Subject digest:
c8da77f549de05b9fb82c3dd1cac0252ca5c23d89ea6e4e64316ffbd7a9328e8 - Sigstore transparency entry: 1266956596
- Sigstore integration time:
-
Permalink:
Rvey/swarm-forge@40d1470275b1ef9ab32261d1bc05664584ed162a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Rvey
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@40d1470275b1ef9ab32261d1bc05664584ed162a -
Trigger Event:
push
-
Statement type: