GitRead 中文社区
首页趋势排行榜原创文章严选周刊
更多资源
新手训练营
精选专题热门话题GitHub 文档资源精选实战指南

swarms

企业级多智能体编排框架。网站:https://swarms.ai

  • 语言Python
  • 大小186.3 MB
  • 更新5 小时前
  • Issues469
在 GitHub 打开
avatarkyegomez

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

拆解 swarms:企业级多智能体编排框架的工程取舍

项目背景与痛点

大模型能力再强,单体的上下文窗口和角色设定终究有限。当一个任务需要"研究员 + 编码员 + 审核员"协作、需要并发跑上百条链路、需要把结果沉淀成可审计的结构化数据时,市面上多数多智能体框架就露出了短板:要么把拓扑焊死成一条线性流水线,要么在并发场景下退化成同步阻塞,要么抽象过度、可观测性缺失,很难扛住生产环境的流量。

kyegomez/swarms 的定位很直接——面向企业的多智能体编排。它不想做一个玩具 Demo 框架,而是试图把"拓扑选择、并发调度、模型解耦、结构化输出"这几件工程上真正要命的事,做成可组合的基础设施。理解这个定位,是读懂它的钥匙。

核心技术揭秘

从架构上看,swarms 做了两层关键抽象:Agent 层与Swarm 层。前者统一了各家模型的调用接口(OpenAI、Anthropic、HuggingFace 等),把工具调用、记忆检索、结果校验收敛到 BaseAgent;后者把"多智能体如何协作"抽象成可路由的拓扑,由 SwarmRouter 统一入口,根据任务特征选择策略。

这背后其实是经典的策略模式 + 路由模式组合:调用方不关心底下是顺序执行还是层级委派,只面向 Router 编程;而真正的调度逻辑被封装进各类 Swarm 实现里。并发路径依赖 asyncio 做异步编排,这是它能撑住高并发批处理的底层原因。

数据流大致是这样:请求进来后先经 Router 判定拓扑,再落到具体的 Swarm 执行器,执行器把任务拆给多个 Agent,Agent 内部完成工具调用与(可选的)记忆召回,最终结果再做一次聚合与结构化收敛。

graph TD A[用户请求] --> B[SwarmRouter 路由] B --> C{"选择 Swarm 拓扑"} C -->|"顺序"| D[SequentialSwarm] C -->|"并发"| E[ConcurrentSwarm] C -->|"层级"| F[HierarchicalSwarm] C -->|"混合"| G[MixtureOfAgents] D --> H[BaseAgent 执行层] E --> H F --> H G --> H H --> I[工具调用与记忆检索] I --> J[LLM Provider 适配] J --> K[结构化输出聚合] K --> L[返回结果]

真正值得注意的设计细节有两个:一是结构化输出——借助 Pydantic 模型约束 Agent 返回,避免下游还要写正则去"刮"自由文本;二是记忆与工具的解耦,记忆后端(向量库等)和工具集都可插拔,这让框架不至于被某一套技术栈绑死。

功能亮点与差异

相比 CrewAI 偏"角色剧本"、AutoGen 偏"对话驱动"的路线,swarms 的差异点在于拓扑的丰富度与工程完备性:

  • 内置多种协作拓扑:顺序、并发、层级委派、MoA(混合专家)、群聊、森林(树状分派)等,开箱即用。特别是层级拓扑,对"经理 Agent 分派给下属 Agent"这种真实组织结构建模很友好。
  • 并发优先的执行模型:Batch 场景下异步并发是硬需求,这一点上比同步框架有先天优势。
  • 模型与工具的中立性:Provider 适配层做得比较薄,替换模型成本低,避免锁定某一家。
  • 结构化产出与记忆生态:把生产环境关心的"结果可解析、上下文可复用"当成一等公民。

换句话说,它不是"为了多智能体而多智能体",而是把多智能体当成一种可被编排、可被监控的计算资源来管理。

应用场景与落地建议

它适合的场景很明确:需要多角色协作或大批量并行处理的分析型任务——比如研报生成、批量内容审核、客服工单分级、多源数据汇总、代码评审流水线。

上生产前,有几件事必须先想清楚:

  1. 成本与限流:并发拓扑会让 token 消耗呈倍增态势,务必在 Agent 层做预算控制与速率限制,否则一次批处理就能烧穿账单。
  2. 失败重试与幂等:LLM 调用天然不稳定,Agent 输出要能校验、能重试,关键链路要设计降级策略。
  3. 可观测性:多智能体的调用链比单体复杂得多,建议在 Router 和 Agent 层埋点,记录每次委派、回传、耗时与成本。
  4. 提示注入防护:Agent 之间传递的上下文可能携带恶意指令,尤其是工具调用环节,需要隔离与清洗。

综合评价

优点:拓扑设计成熟、并发模型到位、Provider 与工具解耦清晰,企业级特性(结构化输出、记忆、可插拔)覆盖得比较全,是少数真正考虑过"上生产"的多智能体框架。

短板:项目迭代速度快,API 变更是常态,版本间的破坏性改动会带来升级成本;抽象层较多,初学者容易在 Router、Swarm、Agent 三者的边界上绕晕;文档与最佳实践的沉淀仍在补齐,社区规模相比头部竞品还有差距。

一句话总结:它更像一套"多智能体运行时",而非一个简单的 Agent 脚手架。如果你的业务需要把协作流程当作工程系统来治理,swarms 值得认真评估;但如果只是想快速跑个对话式 Demo,CrewAI 这类轻量方案可能上手更快。

内容更新时间:4 天前。 编辑团队负责选题与抽样审核,详见 编辑准则。

相关仓库

public-apis/public-apis avatar
public-apispublic-apis
1 天前
498.5k
54.4k
67

免费 API 汇总列表

apipublic-apisfree+7
Python
15.7 MB
7
详情
EbookFoundation/free-programming-books avatar
free-programming-booksEbookFoundation
4 小时前
401.5k
67.7k
91

免费可获取的编程书籍

bookseducationhacktoberfest+2
Python
21.8 MB
3
详情
donnemartin/system-design-primer avatar
system-design-primerdonnemartin
9月15日
377.7k
59.3k
647

学习如何设计大规模系统。为系统设计面试做准备。包含 Anki 闪卡。

designdesign-patternsdesign-system+10
Python
11.0 MB
0
详情
vinta/awesome-python avatar
awesome-pythonvinta
4 天前
334.3k
29.1k
24

回答“我想用 Python 做 X,该用哪个工具?”的权威清单

awesomeawesome-listpython+3
Python
6.9 MB
2
详情
practical-tutorials/project-based-learning avatar
project-based-learningpractical-tutorials
3 天前
289.6k
36.8k
234

精选的项目实战教程列表

tutorialprojectbeginner-project+5
Python
472 KB
1
详情
NousResearch/hermes-agent avatar
hermes-agentNousResearch
2 小时前
262.9k
59.2k
54.0k

与你共同成长的智能体

aiai-agentai-agents+10
Python
1.4 GB
3
详情
TheAlgorithms/Python avatar
PythonTheAlgorithms
1 天前
226.0k
51.3k
106

所有算法均用 Python 实现

algorithmalgorithm-competitionsalgorithms-implemented+11
Python
17.9 MB
2
详情
yt-dlp/yt-dlp avatar
yt-dlpyt-dlp
1 周前
207.2k
18.2k
2.8k

功能丰富的命令行音视频下载器

youtube-dlpythonsponsorblock+4
Python
63.5 MB
0
详情

关于

agentic-aiagentic-workflowagentsaiartificial-intelligencechatgptclaude-codegpt4allhuggingfacelangchainlangchain-pythonmachine-learningmulti-agent-systemsprompt-engineeringprompt-toolkitpromptingswarmstree-of-thoughts
  • Apache License 2.0
  • 7.4k Stars
  • 1.1k Forks
  • 64 Watching

简要分析

热度分
9576
价值分
4727
活跃状态
活跃
GitHub

语言占比

Dockerfile
Python

Release

  • 6.8.12024年12月28日
  • 5.3.72024年7月15日
  • 2.5.02023年12月2日
  • 2.4.22023年11月26日
  • 2.3.12023年11月15日

贡献者

kyegomezkyegomezelder-pliniuselder-pliniusdependabot[bot]dependabot[bot]IlumCIIlumCIayaangazaliayaangazaliharshalmore31harshalmore31evelynmitchellevelynmitchellSteve-DustySteve-DustyWyatt-StankeWyatt-Stankeascender1729ascender1729adichaudharyadichaudharyKpeguero16Kpeguero16
Logo

Swarms Website   •   Documentation   •   Swarms Marketplace   •   中文

Version Downloads Twitter Discord

Overview

Swarms, The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework

Build, deploy, and scale high-performance multi-agent systems with Swarms Python, a fast, flexible, and optimized agent framework. Featuring production-ready harnesses for sequential, concurrent, and hierarchical architectures, seamless framework compatibility, and integrations with MCP, x402, and skills.

Install

# pip
$ pip3 install -U swarms

# uv (recommended): https://github.com/astral-sh/uv
$ uv pip install swarms

# poetry
$ poetry add swarms

From source

# Clone the repository
$ git clone https://github.com/kyegomez/swarms.git
$ cd swarms
$ pip install -r requirements.txt

Faster model calls and graphs with swarms[fast]

swarms[fast] adds two optional speedups:

  • RouteHub for faster model calls through a drop-in LLM gateway. No code changes needed. To switch back to litellm, set SWARMS_LLM_BACKEND=litellm.
  • rustworkx, a graph library written in Rust, for faster GraphWorkflow graphs. Turn it on with GraphWorkflow(backend="rustworkx").
$ pip3 install -U "swarms[fast]"

Using Docker

The official image, swarmscorp/swarms on Docker Hub, has swarms and its CLI installed on Python 3.13, for linux/amd64 and linux/arm64.

# Pull the image
$ docker pull swarmscorp/swarms:latest

# Run a script from the current directory, passing your API key from the shell
$ docker run --rm -e OPENAI_API_KEY -v "$PWD:/app" swarmscorp/swarms python agent.py

# Open a Python shell with swarms installed
$ docker run -it --rm -e OPENAI_API_KEY swarmscorp/swarms

To build the image yourself, run docker build -t swarms . from the repository root.


Environment Configuration

Learn more about the environment configuration here

OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
SWARMS_TELEMETRY_ON

Your First Agent

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?")

Autonomous Agent with 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.

from swarms import Agent

agent = Agent(
    agent_name="Autonomous-Research-Agent",
    agent_description="An autonomous agent that conducts multi-step research independently.",
    system_prompt=(
        "You are an autonomous research agent. Break down complex tasks into steps, "
        "execute each step thoroughly, and signal completion only when the full task is done."
    ),
    model_name="gpt-5.4",
    max_loops="auto",       # Agent decides when it's done; no fixed iteration cap
    autosave=True,
    verbose=True,
)

# The agent will keep looping (planning, executing, and reflecting) until it
# determines the task is fully complete.
result = agent.run(
    "Research the current state of quantum computing, identify the top three "
    "hardware approaches, and summarize the key challenges each faces."
)
print(result)

Use max_loops="auto" for open-ended research, iterative refinement, or any task where the number of steps depends on intermediate results. Use a fixed max_loops value for latency- or cost-sensitive production pipelines and tasks with a well-defined number of steps.

MCP Integration

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."
    )
)

Serve an Agent as an MCP Server

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

Your First Swarm: Multi-Agent Collaboration

A Swarm is multiple agents working together. This example chains a researcher and a writer to produce a blog post. Learn More About SequentialWorkflow

from swarms import Agent, SequentialWorkflow

# Agent 1: The Researcher
researcher = Agent(
    agent_name="Researcher",
    system_prompt="Your job is to research the provided topic and provide a detailed summary.",
    model_name="gpt-5.4",
)

# Agent 2: The Writer
writer = Agent(
    agent_name="Writer",
    system_prompt="Your job is to take the research summary and write a beautiful, engaging blog post about it.",
    model_name="gpt-5.4",
)

# Create a sequential workflow where the researcher's output feeds into the writer's input
workflow = SequentialWorkflow(agents=[researcher, writer])

# Run the workflow on a task
final_post = workflow.run("The history and future of artificial intelligence")
print(final_post)


Available Multi-Agent Architectures

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


SequentialWorkflow

A SequentialWorkflow runs agents in a strict order, with each agent building on the previous one’s output. Use it for processes with clear, ordered steps that depend on each other.

from swarms import Agent, SequentialWorkflow

researcher = Agent(
    agent_name="Researcher",
    system_prompt="Your job is to research the provided topic and provide a detailed summary.",
    model_name="gpt-5.4",
)

writer = Agent(
    agent_name="Writer",
    system_prompt="Your job is to take the research summary and write a beautiful, engaging blog post about it.",
    model_name="gpt-5.4",
)

workflow = SequentialWorkflow(agents=[researcher, writer])

final_post = workflow.run("The history and future of artificial intelligence")
print(final_post)

ConcurrentWorkflow

A ConcurrentWorkflow runs multiple agents on the same task in parallel. It cuts execution time for high-throughput work where agents don’t depend on each other.

from swarms import Agent, ConcurrentWorkflow

market_analyst = Agent(
    agent_name="Market-Analyst",
    system_prompt="Analyze market trends and provide insights on the given topic.",
    model_name="gpt-5.4",
    max_loops=1,
)

financial_analyst = Agent(
    agent_name="Financial-Analyst", 
    system_prompt="Provide financial analysis and recommendations on the given topic.",
    model_name="gpt-5.4",
    max_loops=1,
)

risk_analyst = Agent(
    agent_name="Risk-Analyst",
    system_prompt="Assess risks and provide risk management strategies for the given topic.",
    model_name="gpt-5.4", 
    max_loops=1,
)

concurrent_workflow = ConcurrentWorkflow(
    agents=[market_analyst, financial_analyst, risk_analyst],
    max_loops=1,
)

results = concurrent_workflow.run(
    "Analyze the potential impact of AI technology on the healthcare industry"
)

print(results)

AgentRearrange

Inspired by einsum, AgentRearrange defines relationships between agents with a simple string syntax, where -> runs agents in sequence and , runs them in parallel. Use it to mix sequential and parallel steps in any combination. Learn more

from swarms import Agent, AgentRearrange

researcher = Agent(agent_name="researcher", model_name="gpt-5.4")
writer = Agent(agent_name="writer", model_name="gpt-5.4")
editor = Agent(agent_name="editor", model_name="gpt-5.4")

flow = "researcher -> writer, editor"

rearrange_system = AgentRearrange(
    agents=[researcher, writer, editor],
    flow=flow,
)

outputs = rearrange_system.run("Analyze the impact of AI on modern cinema.")
print(outputs)

GraphWorkflow

GraphWorkflow runs agents as nodes in a Directed Acyclic Graph (DAG), where each edge is a dependency and independent branches run in parallel. Use it for fan-out / fan-in, diamond patterns, or any structure that isn’t a simple line or parallel batch. Learn more about GraphWorkflow

from swarms import Agent, GraphWorkflow

researcher = Agent(agent_name="Researcher", system_prompt="Research the topic and list the key findings.", model_name="gpt-5.4")
writer = Agent(agent_name="Writer", system_prompt="Write a clear article from the research.", model_name="gpt-5.4")
reviewer = Agent(agent_name="Reviewer", system_prompt="Review the article for accuracy and clarity.", model_name="gpt-5.4")

workflow = GraphWorkflow()
workflow.add_nodes([researcher, writer, reviewer])
workflow.add_edge(researcher, writer)
workflow.add_edge(writer, reviewer)

print(workflow.run("Write a short article on the rise of small language models."))

SwarmRouter: The Universal Swarm Orchestrator

SwarmRouter gives you a single interface to run any type of swarm. Change swarm_type (for example to "ConcurrentWorkflow" or "HierarchicalSwarm") to run the same agents with a different strategy. Read the full documentation

from swarms import Agent, SwarmRouter

writer = Agent(agent_name="Writer", system_prompt="You are a creative writer.", model_name="gpt-5.4")
editor = Agent(agent_name="Editor", system_prompt="You are an expert editor for stories.", model_name="gpt-5.4")

router = SwarmRouter(
    agents=[writer, editor],
    swarm_type="SequentialWorkflow",
)

print(router.run("Write a short story about a robot who discovers music."))

AutoSwarmBuilder: Autonomous Agent Generation

AutoSwarmBuilder generates specialized agents, their prompts, and their workflow from a description of your task. Use it for rapid prototyping or to build a team without configuring each agent by hand. Learn more about AutoSwarmBuilder

from swarms import AutoSwarmBuilder
import json

swarm = AutoSwarmBuilder(
    name="My Swarm",
    description="A swarm of agents",
    verbose=True,
    max_loops=1,
    return_agents=True,
    model_name="gpt-5.4",
)

result = swarm.run(
    task="Create an accounting team to analyze crypto transactions, "
         "there must be 5 agents in the team with extremely extensive prompts. "
         "Make the prompts extremely detailed and specific and long and comprehensive. "
         "Make sure to include all the details of the task in the prompts."
)

print(json.dumps(result, indent=4))

MixtureOfAgents (MoA)

MixtureOfAgents sends a task to multiple expert agents in parallel. An aggregator agent then synthesizes their outputs into one final answer. Learn more here

from swarms import Agent, MixtureOfAgents

financial_analyst = Agent(agent_name="FinancialAnalyst", system_prompt="Analyze financial data.", model_name="gpt-5.4")
market_analyst = Agent(agent_name="MarketAnalyst", system_prompt="Analyze market trends.", model_name="gpt-5.4")
risk_analyst = Agent(agent_name="RiskAnalyst", system_prompt="Analyze investment risks.", model_name="gpt-5.4")

aggregator = Agent(
    agent_name="InvestmentAdvisor",
    system_prompt="Synthesize the financial, market, and risk analyses to provide a final investment recommendation.",
    model_name="gpt-5.4"
)

moa_swarm = MixtureOfAgents(
    agents=[financial_analyst, market_analyst, risk_analyst],
    aggregator_agent=aggregator,
)

recommendation = moa_swarm.run("Should we invest in NVIDIA stock right now?")
print(recommendation)

GroupChat

In GroupChat, every agent bids each turn with a score for how much it wants to speak, and the highest bidder above threshold posts its reply. The chat ends when no agent clears threshold or max_loops messages have been posted, and every agent must carry RESPOND_TOOL so it can bid.

from swarms import Agent, GroupChat, RESPOND_TOOL

tech_optimist = Agent(
    agent_name="TechOptimist",
    system_prompt="Argue for the benefits of AI in society.",
    model_name="gpt-5.4",
    max_loops=1,
    persistent_memory=False,
    tools_list_dictionary=[RESPOND_TOOL],
)
tech_critic = Agent(
    agent_name="TechCritic",
    system_prompt="Argue against the unchecked advancement of AI.",
    model_name="gpt-5.4",
    max_loops=1,
    persistent_memory=False,
    tools_list_dictionary=[RESPOND_TOOL],
)

chat = GroupChat(
    agents=[tech_optimist, tech_critic],
    max_loops=10,
    threshold=0.5,
)

result = chat.run("Let's discuss the societal impact of artificial intelligence.")
print(result)

HierarchicalSwarm

In a HierarchicalSwarm, a director agent creates a plan and assigns tasks to specialized worker agents. The director then reviews their results and can issue new orders over several loops.

from swarms import Agent, HierarchicalSwarm

content_strategist = Agent(
    agent_name="Content-Strategist",
    system_prompt="You are a senior content strategist. Develop comprehensive content strategies, editorial calendars, and content roadmaps.",
    model_name="gpt-5.4"
)

creative_director = Agent(
    agent_name="Creative-Director", 
    system_prompt="You are a creative director. Develop compelling advertising concepts, visual directions, and campaign creativity.",
    model_name="gpt-5.4"
)

seo_specialist = Agent(
    agent_name="SEO-Specialist",
    system_prompt="You are an SEO expert. Conduct keyword research, optimize content, and develop organic growth strategies.",
    model_name="gpt-5.4"
)

brand_strategist = Agent(
    agent_name="Brand-Strategist",
    system_prompt="You are a brand strategist. Develop brand positioning, identity systems, and market differentiation strategies.",
    model_name="gpt-5.4"
)

marketing_swarm = HierarchicalSwarm(
    name="Marketing-Team-Swarm",
    description="A comprehensive marketing team with specialized agents coordinated by a director",
    agents=[content_strategist, creative_director, seo_specialist, brand_strategist],
    max_loops=2,
    verbose=True
)

result = marketing_swarm.run(
    "Develop a comprehensive marketing strategy for a new SaaS product launch. "
    "The product is a project management tool targeting small to medium businesses. "
    "Coordinate the team to create content strategy, creative campaigns, SEO optimization, "
    "and brand positioning that work together cohesively."
)

print(result)

HeavySwarm

Inspired by Grok Heavy, HeavySwarm generates questions about a task, runs specialized research, analysis, alternatives, and verification agents in parallel, and synthesizes their findings. The example below uses exa_search from swarms-tools (pip install swarms-tools). Learn more about HeavySwarm

from swarms import HeavySwarm

from swarms_tools import exa_search

swarm = HeavySwarm(
    name="Gold ETF Research Team",
    description="A team of agents that research the best gold ETFs",
    worker_model_name="claude-sonnet-4-20250514",
    show_dashboard=True,
    question_agent_model_name="gpt-5.4",
    loops_per_agent=1,
    agent_prints_on=False,
    worker_tools=[exa_search],
    random_loops_per_agent=True,
)

prompt = (
    "Find the best 3 gold ETFs. For each ETF, provide the ticker symbol, "
    "full name, current price, expense ratio, assets under management, and "
    "a brief explanation of why it is considered among the best. Present the information "
    "in a clear, structured format suitable for investors. Scrape the data from the web. "
)

out = swarm.run(prompt)
print(out)

Social Algorithms

Social Algorithms let you define custom communication patterns between agents. You pass a callable that decides which agent talks to which, and in what order. Learn more about Social Algorithms

from swarms import Agent, SocialAlgorithms

def research_analysis_synthesis_algorithm(agents, task, **kwargs):
    research_result = agents[0].run(f"Research: {task}")
    analysis = agents[1].run(f"Analyze this research: {research_result}")
    synthesis = agents[2].run(f"Synthesize: {research_result} + {analysis}")
    return {
        "research": research_result,
        "analysis": analysis,
        "synthesis": synthesis
    }

researcher = Agent(
  agent_name="Researcher",
  agent_description="Expert in comprehensive research and information gathering.",
  model_name="gpt-5.4"
)
analyst = Agent(
  agent_name="Analyst",
  agent_description="Specialist in analyzing and interpreting data.",
  model_name="gpt-5.4"
)
synthesizer = Agent(
  agent_name="Synthesizer",
  agent_description="Focused on synthesizing and integrating research insights.",
  model_name="gpt-5.4"
)

social_alg = SocialAlgorithms(
    name="Research-Analysis-Synthesis",
    agents=[researcher, analyst, synthesizer],
    social_algorithm=research_analysis_synthesis_algorithm,
    verbose=True
)

result = social_alg.run("The impact of AI on healthcare")
print(result.final_outputs)

Documentation

The full documentation lives at docs.swarms.world. Below are the resources most useful when building with Swarms, both for humans and for AI coding assistants.

Resource Link What it’s for
Main documentation docs.swarms.world Guides, API reference, tutorials
llms.txt (LLM-ingestible docs) docs.swarms.world/llms.txt A single, machine-readable index of the entire documentation, formatted for LLMs and AI IDEs (Cursor, Claude Code, etc.) to consume in one fetch
Docs MCP server https://docs.swarms.world/mcp A Model Context Protocol server that lets an assistant search and read the current docs. See Using Swarms with AI Coding Assistants
MCP integration guide docs.swarms.world/integrations/mcp How to connect a Swarms Agent to any MCP server, auto-discover its tools, and call them from a swarm
API reference docs.swarms.world/api Per-class reference for Agent, SequentialWorkflow, ConcurrentWorkflow, AgentRearrange, GraphWorkflow, SwarmRouter, and every multi-agent architecture
Environment setup docs.swarms.world/environment-setup API keys, model providers, and configuration options

Tip for AI coding assistants: point your tool (Claude Code, Cursor, Windsurf, Continue, etc.) at https://docs.swarms.world/llms.txt. It will pull the entire docs index in one shot and write idiomatic Swarms code without per-question lookups.


Using Swarms with AI Coding Assistants

The repo ships with AGENTS.md and CLAUDE.md, guides that teach AI coding assistants (Claude Code, Cursor, Codex, Copilot and others) how to build with Swarms: the Agent primitive, every multi-agent architecture, tools, streaming, memory and MCP.

Copy CLAUDE.md (or symlink it as AGENTS.md / .cursorrules) into any project that uses swarms, and your assistant will write idiomatic Swarms code from the start.

Two hosted MCP servers give an assistant live Swarms context instead of training data that may predate a rename:

Server URL Key What it does
Docs https://docs.swarms.world/mcp none Searches and reads the current documentation
Marketplace https://swarms.world/mcp Swarms API key for calls Searches, reads and publishes agents, prompts and tools on swarms.world

The whole documentation is also available as plain text at docs.swarms.world/llms.txt (an index) and docs.swarms.world/llms-full.txt (every page).

Claude Code:

claude mcp add --transport http swarms-docs https://docs.swarms.world/mcp
claude mcp add --transport http swarms-marketplace https://swarms.world/mcp \
  --header "Authorization: Bearer $SWARMS_API_KEY"

Cursor, in .cursor/mcp.json:

{
  "mcpServers": {
    "swarms-docs": { "url": "https://docs.swarms.world/mcp" },
    "swarms-marketplace": {
      "url": "https://swarms.world/mcp",
      "headers": { "Authorization": "Bearer ${env:SWARMS_API_KEY}" }
    }
  }
}

Features

Swarms delivers a comprehensive, enterprise-grade multi-agent infrastructure platform designed for production-scale deployments and seamless integration with existing systems. Learn more about the swarms feature set here

Category Features Benefits
Enterprise Architecture • Production-Ready Infrastructure
• High Availability Systems
• Modular Microservices Design
• Comprehensive Observability
• Backwards Compatibility
• 99.9%+ Uptime Guarantee
• Reduced Operational Overhead
• Seamless Legacy Integration
• Enhanced System Monitoring
• Risk-Free Migration Path
Multi-Agent Orchestration • Hierarchical Agent Swarms
• Parallel Processing Pipelines
• Sequential Workflow Orchestration
• Graph-Based Agent Networks
• Dynamic Agent Composition
• Agent Registry Management
• Complex Business Process Automation
• Scalable Task Distribution
• Flexible Workflow Adaptation
• Optimized Resource Utilization
• Centralized Agent Governance
• Enterprise-Grade Agent Lifecycle Management
Enterprise Integration • Multi-Model Provider Support
• Custom Agent Development Framework
• Extensive Enterprise Tool Library
• Multiple Memory Systems
• Backwards Compatibility with LangChain, AutoGen, CrewAI
• Standardized API Interfaces
• Vendor-Agnostic Architecture
• Custom Solution Development
• Extended Functionality Integration
• Enhanced Knowledge Management
• Seamless Framework Migration
• Reduced Integration Complexity
Enterprise Scalability • Concurrent Multi-Agent Processing
• Intelligent Resource Management
• Load Balancing & Auto-Scaling
• Horizontal Scaling Capabilities
• Performance Optimization
• Capacity Planning Tools
• High-Throughput Processing
• Cost-Effective Resource Utilization
• Elastic Scaling Based On Demand
• Linear Performance Scaling
• Optimized Response Times
• Predictable Growth Planning
Developer Experience • Intuitive Enterprise API
• Comprehensive Documentation
• Active Enterprise Community
• CLI & SDK Tools
• IDE Integration Support
• Code Generation Templates
• Accelerated Development Cycles
• Reduced Learning Curve
• Expert Community Support
• Rapid Deployment Capabilities
• Enhanced Developer Productivity
• Standardized Development Patterns

Supported Protocols & Integrations

Swarms seamlessly integrates with industry-standard protocols and open specifications, unlocking powerful capabilities for tool integration, payment processing, distributed agent orchestration, and model interoperability.

Protocol Description Documentation
MCP (Model Context Protocol) Standardized protocol for AI agents to interact with external tools and services through MCP servers. Enables dynamic tool discovery and execution. MCP Integration Guide
A2A (Agent2Agent) Open protocol for agents built on different frameworks to discover and call each other. A2AServer serves any agent or swarm with a public agent card and a SendMessage endpoint, and A2AClient calls any remote A2A 1.0 agent. A2A Examples
X402 Cryptocurrency payment protocol for API endpoints. Enables monetization of agents with pay-per-use models. X402 Quickstart
Swarms Marketplace Platform for discovering and sharing production-ready prompts, agents, and tools. Enables automatic prompt loading from the marketplace and publishing your own prompts directly from code. Marketplace Tutorial
Open Responses Open-source specification and ecosystem for multi-provider, interoperable LLM interfaces based on the OpenAI Responses API. Provides a unified schema and tooling for calling language models, streaming results, and composing agentic workflows, independent of provider. Open Responses Website
Agent Skills Lightweight, markdown-based format for defining modular, reusable agent capabilities introduced by Anthropic. Enables specialization of agents without modifying code by loading skill definitions from simple SKILL.md files. Agent Skills Documentation

Examples

Explore comprehensive examples and tutorials to learn how to use Swarms effectively HERE


Contribute to Swarms

Swarms is an open-source, community-driven framework aiming to accelerate a fully autonomous world by providing robust infrastructure for deploying and orchestrating millions of agents. By contributing, you can help advance multi-agent AI, collaborate with passionate peers, shape the agent economy, and enhance your expertise.

Learn more about how you can make a meaningful impact in our Contributor’s Guide.

How to Contribute

We’ve made it easy to start contributing. Here’s how you can help:

  1. Find an Issue to Tackle: The best way to begin is by visiting our contributing project board. Look for issues tagged with good first issue; these are specifically selected for new contributors.

  2. Report a Bug or Request a Feature: Have a new idea or found something that isn’t working right? We’d love to hear from you. Please file a Bug Report or Feature Request on our GitHub Issues page.

  3. Understand Our Workflow and Standards: Before submitting your work, please review our complete Contribution Guidelines. To help maintain code quality, we also encourage you to read our guide on Code Cleanliness.

  4. Join the Discussion: To participate in roadmap discussions and connect with other developers, join our community on Discord.

  5. Use WARP for Every Commit, PR and Issue: All contributors, people and AI agents alike, must write commit messages, PR titles and issue titles in the WARP (Warp Speed Protocol) shorthand: [TYPE][Function/FileName][Short Description], for example [FIX][Agent._run][Raise AgentLLMError after retry exhaustion]. The full spec is the WARP Git Message Skill. Issues and PRs that skip WARP are triaged after the ones that use it, so expect a delay without it.

Thank You to Our Contributors

Thank you for contributing to swarms. Your work is extremely appreciated and recognized.

Join Swarms

Our mission is to advance humanity by building the infrastructure that powers the agent economy. We’re actively recruiting talented individuals across multiple roles to accelerate this vision. Join our team to help build, maintain, and scale the Swarms Python package, Swarms Marketplace, and our growing suite of products.

  • Check Open roles: swarms.ai/hiring

  • Get in touch: email [email protected] to learn more

Join the Discord

Join thousands of agent builders and AI engineers in the Swarms Discord for technical support, project showcases, collaboration, and the latest swarms ecosystem updates.

Join the Swarms Discord →


Join the Swarms Community!

Join our community of agent engineers and researchers for technical support, cutting-edge updates, and exclusive access to world-class agent engineering insights!

Platform Description Link
Documentation Official documentation and guides docs.swarms.world
Blog Latest updates and technical articles Medium
Discord Live chat and community support Join Discord
Twitter Latest news and announcements @swarms_corp
LinkedIn Professional network and updates The Swarm Corporation
YouTube Tutorials and demos Swarms Channel
Events Join our community events Sign up here
Onboarding Session Get onboarded with Kye Gomez, creator and lead maintainer of Swarms Book Session

Citation

If you use swarms in your research, please cite the project by referencing the metadata in CITATION.cff.

@misc{SWARMS_2022,
  author  = {Kye Gomez and Pliny and Zack Bradshaw and Ilumn and Harshal and the Swarms Community},
  title   = {{Swarms: Production-Grade Multi-Agent Infrastructure Platform}},
  year    = {2022},
  howpublished = {\url{https://github.com/kyegomez/swarms}},
  note    = {Documentation available at \url{https://docs.swarms.world}},
  version = {latest}

License

Swarms is licensed under the Apache License 2.0. Learn more here

评论

登录 后发表评论
暂无评论
GitRead 中文社区
深度解读 · 趋势洞察 · 价值精选

关于

关于我们联系我们编辑准则收录标准赞赏人员

发现

技术趋势新手训练营资源精选实战指南精选专题热门话题GitHub 文档

条款

隐私政策服务条款网站地图
26.9万收录项目
6.8万中文话题
155精选专题
发现技术价值,连接开源智慧
© 2026 GitRead · GitHub 中文社区 本站与 GitHub, Inc. 无隶属关系;GitHub 是 GitHub, Inc. 的商标。