LLM-agnostic · Python 3.11+

Build AI agents in Python —
from one assistant to multi-agent teams.

Provider-agnostic runtimes, persistent memory, hierarchical agent graphs, and Clean Architecture — swap any layer without rewriting your code.

$ pip install swarmline[thin]
PyPI versionPyPI downloads per monthSupported Python versions
  • 4providers
  • 6runtimes
  • 14protocols
  • MITlicense
agent.py
from swarmline import Agent, AgentConfig

agent = Agent(AgentConfig(
    system_prompt="You are a helpful assistant.",
    runtime="thin",
))
result = await agent.query("What is the capital of France?")
print(result.text)
stream.py
agent = Agent(AgentConfig(system_prompt="...", runtime="thin"))

async for event in agent.stream("Explain quantum computing"):
    if event.type == "text_delta":
        print(event.text, end="", flush=True)
structured.py
agent = Agent(AgentConfig(
    system_prompt="Extract user info.",
    runtime="thin",
    output_format={
        "type": "object",
        "properties": {
            "name": {"type": "string"},
            "age": {"type": "integer"},
        },
    },
))
result = await agent.query("John is 30 years old")
print(result.structured_output)  # {"name": "John", "age": 30}
Why Swarmline

One framework for the whole spectrum.

The same API takes you from a quick single-agent script to a governed multi-agent system in production.

Swap providers, not code

Anthropic, OpenAI, Google, and DeepSeek sit behind one config. Change the model with a single line — your agent code never changes.

From 3 lines to org charts

Start with a single assistant in 3 lines. Scale to hierarchical agent graphs with governance, delegation, and DAG task boards — same API.

Remembers, and stays clean

Persistent episodic and procedural memory across sessions, built on 14 ISP protocols you can swap at every layer — InMemory, SQLite, or Postgres.

Features

Power where you need it, restraint where you don’t.

Every capability is an independent toggle on a protocol you can replace. Explore a few:

Six runtimes, one business code

thin · claude_sdk · deepagents · cli · openai_agents · pi_sdk. Switch the execution engine with a single config field — everything else stays put.

python
# same code — pick the engine that fits
Agent(AgentConfig(system_prompt="...", runtime="thin"))           # built-in multi-provider loop
Agent(AgentConfig(system_prompt="...", runtime="claude_sdk"))     # Claude Agent SDK + MCP
Agent(AgentConfig(system_prompt="...", runtime="deepagents"))     # LangGraph graph runtime
Agent(AgentConfig(system_prompt="...", runtime="openai_agents"))  # OpenAI Agents SDK

Hierarchical teams with governance

Compose org charts with a builder DSL — roots, children, delegation, and a task board with DAG dependencies and budget gates.

python
await (GraphBuilder(store)
    .add_root("lead", "Lead", "lead", system_prompt="You lead.")
    .add_child("researcher", "lead", "Researcher", "researcher")
    .add_child("coder", "lead", "Coder", "coder")
    .build())

run_id = await orchestrator.start("Build a REST API for user management")
result = await orchestrator.wait_for_task(f"root-{run_id}")

Memory that follows your scale

InMemory, SQLite, and PostgreSQL providers share the same 8 protocols. Prototype in memory, ship on Postgres — no code change. Episodic + procedural recall built in.

python
from swarmline.memory import (
    InMemoryMemoryProvider, SQLiteMemoryProvider, PostgresMemoryProvider,
)

memory = InMemoryMemoryProvider()                     # dev
memory = SQLiteMemoryProvider(db_path="./agent.db")   # single-user
memory = PostgresMemoryProvider(session_factory)      # production

Tools from type hints, safe by default

Define tools with @tool — the JSON Schema is inferred from your type hints. A default-deny policy, PreToolUse / PostToolUse hooks, and a middleware chain keep execution under control.

python
@tool(name="word_count", description="Count the words in a text")
async def word_count(text: str) -> str:
    return str(len(text.split()))

agent = Agent(AgentConfig(
    system_prompt="You are a writing assistant.",
    runtime="thin",
    tools=(word_count,),
))
How it compares

The breadth is the point.

Most frameworks cover a slice. Swarmline gives you providers, orchestration, memory, and architecture in one place.

CapabilitySwarmlineLangGraphCrewAIAutoGenDeepAgentsPydantic AIOpenAI AgentsClaude Code SDK
Multi-provider (4+ LLMs)··
Hierarchical agent graph~·~~··
Agent governance & delegation·······
Knowledge bank + search·······
Episodic + procedural memory·~·~···
Pipeline + budget gates··~····
Clean Architecture (ISP)····~··
Default-deny tool security······
Swappable storage backends~··~···
3-line quick start··~

Comparison reflects built-in capabilities at time of writing. See thedocs for the full matrix and caveats.

Capabilities

Batteries included — and replaceable.

Every capability is an independent toggle, built on a protocol you can swap. Turn on only what your agent needs.

Sandbox

Isolated file I/O and command execution — bash, read, write, edit, glob, grep. Host execution stays opt-in.

Web access

Pluggable search and fetch — DuckDuckGo, Tavily, Brave, Jina, Crawl4AI — behind one interface.

Memory

Episodic + procedural recall across sessions, consolidated into a searchable knowledge bank.

Tool policy & hooks

Default-deny allowlists, PreToolUse / PostToolUse hooks, and a pluggable middleware chain.

Planning

Step-by-step task decomposition and execution — plan, status, and run as first-class tools.

Observability

Structured JSON logs via structlog, OpenTelemetry export, and an activity audit trail.

Evaluation

Measure agent quality with custom scorers, compare/history, and console + JSON reporters.

Human-in-the-loop

Approval patterns at the tool, plan, and output level — keep a human in control where it matters.

Get started

From zero to agent in a minute.

No boilerplate, no graph wiring to learn first — start simple and grow into the rest.

  1. 01

    Install

    Pull the core plus the lightweight built-in runtime.

    pip install swarmline[thin]
  2. 02

    Add a provider key

    Any provider works — swap it later with one config change.

    export ANTHROPIC_API_KEY=sk-ant-...
  3. 03

    Write your agent & run

    Three lines to a working agent. Then just run the file.

    python agent.py
agent.py
# agent.py
import asyncio
from swarmline import Agent, AgentConfig

agent = Agent(AgentConfig(
    system_prompt="You are a helpful assistant.",
    runtime="thin",
))

async def main():
    result = await agent.query("Give me 3 ideas for a weekend project.")
    print(result.text)

asyncio.run(main())
Full getting-started guide →
Works with
  • Anthropic
  • OpenAI
  • Google
  • DeepSeek

Build your first agent in three lines.

$ pip install swarmline[thin]
Read the docs →