The Enterprise-Grade Multi-Agent Orchestration Framework. Website: https://swarms.ai
The Enterprise-Grade Multi-Agent Orchestration Framework. Website: https://swarms.ai
Swarms Website • Documentation • Swarms Marketplace • 中文
</picture>
</picture>
</picture>
</picture>
Swarms, The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework
Swarms is the most reliable, scalable, and adaptive multi-agent orchestration framework available today. We provide a comprehensive suite of production-ready, prebuilt multi-agent architectures, including sequential, concurrent, and hierarchical systems. Additionally, Swarms offers backward compatibility with leading agent frameworks and interoperability with protocols such as MCP, x402, skills, and much more.
$ pip3 install -U swarmsuv is a fast Python package installer and resolver, written in Rust.
$ uv pip install swarms$ poetry add swarms# Clone the repository
$ git clone https://github.com/kyegomez/swarms.git
$ cd swarms
$ pip install -r requirements.txtLearn more about the environment configuration here
OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""An Agent is the fundamental building block of a swarm—an autonomous entity powered by an LLM + Tools + Memory. Learn more Here
from swarms import Agent
# Initialize a new agent
agent = Agent(
model_name="gpt-5.4", # Specify the LLM
max_loops="auto", # Set the number of interactions
interactive=True, # Enable interactive mode for real-time feedback
temperature=None,
)
# Run the agent with a task
agent.run("What are the key benefits of using a multi-agent system?")max_loops="auto"Setting max_loops="auto" lets the agent decide for itself when the task is complete — it keeps reasoning and acting until it reaches a stopping condition, rather than halting after a fixed number of iterations. This is the recommended mode for open-ended, multi-step tasks where the number of steps isn't known in advance.
…When to use max_loops="auto":
When to use a fixed max_loops value:
The Model Context Protocol (MCP) lets agents easily access external tools and data by pointing to an MCP server URL, which automatically provides tools to the agent as needed. Agents become MCP-enabled by setting mcp_url or mcp_urls, and can use tools from one or many servers with no manual configuration. Free and public MCP servers like DeepWiki work out of the box, offering immediate access to useful agent tools.
from swarms import Agent
agent = Agent(
agent_name="MCP-Agent",
model_name="claude-sonnet-5",
mcp_url="https://mcp.deepwiki.com/mcp",
max_loops=1,
temperature=None,
max_tokens=16_000,
reasoning_effort=None,
)
print(
agent.run(
"Use your tools to explain what the kyegomez/swarms repository does."
)
)The reverse direction works too. MCPDeployer turns any agent, or any swarm, into an MCP server that other agents and MCP hosts can call, with an auth layer in front of it. Each target becomes one tool; pass a list or a dict to serve several from one server. See the MCPDeployer examples
from swarms import Agent, MCPDeployer
researcher = Agent(
agent_name="Researcher",
agent_description="Answers research questions with a short summary.",
model_name="gpt-5.4",
max_loops=1,
)
# Serves http://127.0.0.1:8000/mcp as the tool "researcher".
MCPDeployer(researcher, api_keys=["sk-local-dev"], port=8000).run()Any other agent can then use it by pointing at the URL with the key:
from swarms import Agent
from swarms.schemas.mcp_schemas import MCPConnection
client = Agent(
agent_name="Client",
model_name="gpt-5.4",
mcp_url=MCPConnection(url="http://127.0.0.1:8000/mcp", api_key="sk-local-dev"),
max_loops=2,
)
client.run("Use the researcher tool to summarise the state of solid-state batteries.")Auth can be static API keys, your own auth callable that reads the request headers, or an mcp TokenVerifier with required scopes. A server with no auth configured refuses to start unless you pass allow_anonymous=True. Transports: streamable HTTP (default), SSE, or stdio for desktop MCP hosts.
| Example | What it shows |
|---|---|
| single_agent_api_key.py | One agent behind a static key |
| multiple_agents_one_server.py | Two agents, a SequentialWorkflow and two functions as separate tools |
| custom_auth_per_tenant.py | Your own async auth callable reading an x-tenant header |
| token_verifier_with_scopes.py | TokenVerifier with required scopes |
| background_server_and_client_agent.py | Serve, call from a second agent, and stop, all in one process |
| All MCPDeployer examples | Every target kind, auth mode and transport |
A Swarm consists of multiple agents working together. This simple example creates a two-agent workflow for researching and writing a blog post. Learn More About SequentialWorkflow
…swarms provides a variety of powerful, pre-built multi-agent architectures enabling you to orchestrate agents in various ways. Choose the right structure for your specific problem to build efficient and reliable production systems.
| Architecture | Description | Best For |
|---|---|---|
| SequentialWorkflow | Agents execute tasks in a linear chain; the output of one agent becomes the input for the next. | Step-by-step processes such as data transformation pipelines and report generation. |
| ConcurrentWorkflow | Agents run tasks simultaneously for maximum efficiency. | High-throughput tasks such as batch processing and parallel data analysis. |
| AgentRearrange | Dynamically maps complex relationships (e.g., a -> b, c) between agents. |
Flexible and adaptive workflows, task distribution, and dynamic routing. |
| GraphWorkflow | Orchestrates agents as nodes in a Directed Acyclic Graph (DAG). | Complex projects with intricate dependencies, such as software builds. |
| MixtureOfAgents (MoA) | Utilizes multiple expert agents in parallel and synthesizes their outputs. | Complex problem-solving and achieving state-of-the-art performance through collaboration. |
| GroupChat | Agents collaborate and make decisions through a conversational interface. | Real-time collaborative decision-making, negotiations, and brainstorming. |
| ForestSwarm | Dynamically selects the most suitable agent or tree of agents for a given task. | Task routing, optimizing for expertise, and complex decision-making trees. |
| HierarchicalSwarm | Orchestrates agents with a director who creates plans and distributes tasks to specialized worker agents. | Complex project management, team coordination, and hierarchical decision-making with feedback loops. |
| HeavySwarm | Implements a five-phase workflow with specialized agents (Research, Analysis, Alternatives, Verification) for comprehensive task analysis. | Complex research and analysis tasks, financial analysis, strategic planning, and comprehensive reporting. |
| SwarmRouter | A universal orchestrator that provides a single interface to run any type of swarm with dynamic selection. | Simplifying complex workflows, switching between swarm strategies, and unified multi-agent management. |
Learn more about all of the 60+ Multi-Agent Structures we have available here
A SequentialWorkflow executes tasks in a strict order, forming a pipeline where each agent builds upon the work of the previous one. SequentialWorkflow is Ideal for processes that have clear, ordered steps. This ensures that tasks with dependencies are handled correctly.
…A ConcurrentWorkflow runs multiple agents simultaneously, allowing for parallel execution of tasks. This architecture drastically reduces execution time for tasks that can be performed in parallel, making it ideal for high-throughput scenarios where agents work on similar tasks concurrently.
…Inspired by einsum, AgentRearrange lets you define complex, non-linear relationships between agents using a simple string-based syntax. Learn more. This architecture is perfect for orchestrating dynamic workflows where agents might work in parallel, in sequence, or in any combination you choose.
…GraphWorkflow orchestrates agents as nodes in a Directed Acyclic Graph (DAG). Each node is an agent and each edge declares a dependency, so a node only runs after every upstream node has finished. A topological sort guarantees correct execution order, while independent branches run in parallel automatically.
This makes GraphWorkflow the right choice when your workflow has fan-out / fan-in patterns, conditional dependencies, or any structure that doesn't fit a strict line or a flat parallel batch. Learn more about GraphWorkflow
…GraphWorkflow excels at:
[BUG][HierarchicalSwarm.prepare_worker_agents][multi_agent_prompt_improvements appends to system_prompt after the LLM is built, so it never reaches the model and piles up]
[BUG][Agent.run][n > 1 drops img, imgs, streaming_callback and kwargs, so every sample runs without the image]
[BUG][AuctionSwarm/_extract_bid][Six copies of the tool-call unwrap accept different provider shapes, so every bid silently ties]
[Bug][AgentRearrange] concurrent_run shares task state and silently truncates image batches
[BUG][AutonomousAgentLoop][tool_search returns irrelevant tools and the subtask stalls instead of continuing]
[BUG] AUTO_GEN_PROMPT Marks Swarm Description as Optional, but YAML Loader Requires It
[BUG] Tool schemas are duplicated into the conversation as an assistant turn
[BUGF][one_on_one_debate][Retain the first answer in default output]
[BUG][LLMCouncil] The Chairman gets the whole council as one user blob (#2053 follow-up)
[FEAT] Add an opt-in Codex CLI backend configurable through Agent/YAML