概述
Swarms,企业级生产就绪的多智能体编排框架
Swarms 是目前最可靠、可扩展且自适应的多智能体编排框架。我们提供一套全面的生产就绪、预构建的多智能体架构,包括顺序、并发和分层系统。此外,Swarms 支持与主流智能体框架的向后兼容,以及与 MCP、x402、skills 等协议的互操作性,等等。
安装
使用 pip
$ pip3 install -U swarms
使用 uv(推荐)
uv 是一个快速的 Python 包安装器和解析器,使用 Rust 编写。
$ uv pip install swarms
使用 poetry
$ poetry add swarms
来自源
# Clone the repository
$ git clone https://github.com/kyegomez/swarms.git
$ cd swarms
$ pip install -r requirements.txt
环境配置
OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
你的第一个 Agent
Agent 是 swarm 的基本构建模块——一个由 LLM + Tools + Memory 驱动的自主实体。在此了解更多
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" 的自主智能体
设置 max_loops="auto" 让智能体自行决定任务何时完成——它会持续推理和行动,直到达到停止条件,而不是在固定次数的迭代后停止。这是开放式、多步骤任务的推荐模式,其中步骤数量无法预先确定。
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)
何时使用 max_loops="auto":
- 开放式研究或分析任务
- 需要迭代优化的任务(例如:编写 → 审查 → 修订)
- 任何步骤数量取决于中间结果的工作流
何时使用固定的 max_loops 值:
- 对延迟敏感或对成本敏感的生产流水线
- 具有明确定义且步骤数量有限的任务
MCP 集成
模型上下文协议 (MCP) 允许智能体通过指向 MCP 服务器 URL 轻松访问外部工具和数据,该 URL 会自动根据需求向智能体提供工具。通过设置 mcp_url 或 mcp_urls,智能体即可启用 MCP 功能,并可使用来自一个或多个服务器的工具,无需手动配置。像 DeepWiki 这样的免费且公开的 MCP 服务器开箱即用,提供对实用智能体工具的即时访问。
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."
)
)
你的第一个 Swarm:多智能体协作
Swarm 由多个协同工作的智能体组成。这个简单示例创建了一个用于研究和撰写博客文章的双智能体工作流。了解更多关于 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)
可用的多智能体架构
swarms 提供了多种强大的预构建多智能体架构,使您能够以多种方式编排智能体。针对您的具体问题选择合适的结构,以构建高效且可靠的生产系统。
| 架构 | 描述 | 适用场景 |
|---|---|---|
| SequentialWorkflow | 代理按线性链执行任务;一个代理的输出成为下一个代理的输入。 | 逐步处理流程,例如数据转换管道和报告生成。 |
| ConcurrentWorkflow | 代理同时运行任务以实现最大效率。 | 高吞吐量任务,例如批处理和并行数据分析。 |
| AgentRearrange | 动态映射代理之间的复杂关系(例如,a -> b, c)。 | 灵活且自适应的工作流、任务分配和动态路由。 |
| GraphWorkflow | 将代理作为有向无环图 (DAG) 中的节点进行编排。 | 具有复杂依赖关系的复杂项目,例如软件构建。 |
| MixtureOfAgents (MoA) | 并行利用多个专家代理并综合其输出。 | 复杂问题解决以及通过协作实现最先进性能。 |
| GroupChat | 代理通过对话界面进行协作和决策。 | 实时协作决策、谈判和头脑风暴。 |
| ForestSwarm | 动态选择最适合给定任务的代理或代理树。 | 任务路由、专长优化和复杂决策树。 |
| HierarchicalSwarm | 通过一位创建计划并向专业工作者智能体分配任务的导演来编排智能体。 | 复杂的项目管理、团队协调以及带有反馈循环的层级决策。 |
| HeavySwarm | 实施包含专业智能体(研究、分析、替代方案、验证)的五阶段工作流,以进行全面的任务分析。 | 复杂的研究与分析任务、财务分析、战略规划以及全面报告。 |
| SwarmRouter | 一种通用编排器,提供单一接口以动态选择并运行任何类型的群体。 | 简化复杂工作流、在群体策略之间切换以及统一的多智能体管理。 |
了解更多关于我们提供的 60 多种 Multi-Agent Structures 的信息,请点击此处
SequentialWorkflow
SequentialWorkflow 按严格顺序执行任务,形成一个流水线,其中每个智能体都在前一个智能体的工作基础上进行构建。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)
ConcurrentWorkflow
一个 ConcurrentWorkflow 同时运行多个智能体,允许并行执行任务。这种架构大幅缩短了可并行执行任务的执行时间,使其非常适合智能体并发处理相似任务的高吞吐量场景。
from swarms import Agent, ConcurrentWorkflow
# Create agents for different analysis tasks
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,
)
# Create concurrent workflow
concurrent_workflow = ConcurrentWorkflow(
agents=[market_analyst, financial_analyst, risk_analyst],
max_loops=1,
)
# Run all agents concurrently on the same task
results = concurrent_workflow.run(
"Analyze the potential impact of AI technology on the healthcare industry"
)
print(results)
AgentRearrange
受 einsum 启发,AgentRearrange 允许你使用简单的基于字符串的语法来定义代理之间复杂的非线性关系。了解更多。该架构非常适合编排动态工作流,其中代理可以并行、顺序或以你选择的任意组合方式工作。
from swarms import Agent, AgentRearrange
# Define agents
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")
# Define a flow: researcher sends work to both writer and editor simultaneously
# This is a one-to-many relationship
flow = "researcher -> writer, editor"
# Create the rearrangement system
rearrange_system = AgentRearrange(
agents=[researcher, writer, editor],
flow=flow,
)
# Run the swarm
outputs = rearrange_system.run("Analyze the impact of AI on modern cinema.")
print(outputs)
GraphWorkflow
GraphWorkflow 将智能体作为有向无环图(DAG)中的节点进行编排。每个节点是一个智能体,每条边声明一个依赖关系,因此一个节点只有在所有上游节点完成后才会运行。拓扑排序保证了正确的执行顺序,而独立的分支会自动并行运行。
当你的工作流具有扇出/扇入模式、条件依赖,或任何不符合严格线性或扁平并行批次的结构时,这使得 GraphWorkflow 成为正确的选择。了解更多关于 GraphWorkflow 的信息
from swarms import Agent, GraphWorkflow, Node, Edge, NodeType
# Define agents
researcher = Agent(agent_name="Researcher", system_prompt="Research the given topic and produce key findings.", model_name="gpt-5.4")
writer = Agent(agent_name="Writer", system_prompt="Write a clear article from the research provided.", model_name="gpt-5.4")
reviewer = Agent(agent_name="Reviewer", system_prompt="Review the article for accuracy and clarity.", model_name="gpt-5.4")
publisher = Agent(agent_name="Publisher", system_prompt="Format the final reviewed article for publication.", model_name="gpt-5.4")
# Build the graph: Researcher -> Writer -> Reviewer -> Publisher
workflow = GraphWorkflow()
workflow.add_node(Node(id="researcher", type=NodeType.AGENT, agent=researcher))
workflow.add_node(Node(id="writer", type=NodeType.AGENT, agent=writer))
workflow.add_node(Node(id="reviewer", type=NodeType.AGENT, agent=reviewer))
workflow.add_node(Node(id="publisher", type=NodeType.AGENT, agent=publisher))
workflow.add_edge(Edge(source="researcher", target="writer"))
workflow.add_edge(Edge(source="writer", target="reviewer"))
workflow.add_edge(Edge(source="reviewer", target="publisher"))
workflow.set_entry_points(["researcher"])
workflow.set_end_points(["publisher"])
# Run the graph
results = workflow.run("Produce a short article on the rise of small language models.")
print(results)
GraphWorkflow 擅长:
- 复杂依赖:表达任意 DAG,包括扇出、扇入和菱形模式
- 自动并行:独立分支无需额外配置即可并发执行
- 节点级可观测性:通过回调钩入节点完成事件,实现流式处理和进度跟踪
SwarmRouter:通用 Swarm 编排器
SwarmRouter 通过提供单一接口来运行任意类型的 swarm,简化了复杂工作流的构建。无需导入和管理不同的 swarm 类,只需更改 swarm_type 参数即可动态选择所需的类。阅读完整文档
这使得您的代码更简洁、更灵活,让您能够轻松地在不同的多智能体策略之间切换。下面是一个完整示例,展示了如何定义智能体,然后使用 SwarmRouter 以不同的协作策略执行相同任务。
from swarms import Agent, SwarmRouter, SwarmType
# Define a few generic agents
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")
reviewer = Agent(agent_name="Reviewer", system_prompt="You are a final reviewer who gives a score.", model_name="gpt-5.4")
# The agents and task will be the same for all examples
agents = [writer, editor, reviewer]
task = "Write a short story about a robot who discovers music."
# --- Example 1: SequentialWorkflow ---
# Agents run one after another in a chain: Writer -> Editor -> Reviewer.
print("Running a Sequential Workflow...")
sequential_router = SwarmRouter(swarm_type=SwarmType.SequentialWorkflow, agents=agents)
sequential_output = sequential_router.run(task)
print(f"Final Sequential Output:\n{sequential_output}\n")
# --- Example 2: ConcurrentWorkflow ---
# All agents receive the same initial task and run at the same time.
print("Running a Concurrent Workflow...")
concurrent_router = SwarmRouter(swarm_type=SwarmType.ConcurrentWorkflow, agents=agents)
concurrent_outputs = concurrent_router.run(task)
# This returns a dictionary of each agent's output
for agent_name, output in concurrent_outputs.items():
print(f"Output from {agent_name}:\n{output}\n")
# --- Example 3: MixtureOfAgents ---
# All agents run in parallel, and a special 'aggregator' agent synthesizes their outputs.
print("Running a Mixture of Agents Workflow...")
aggregator = Agent(
agent_name="Aggregator",
system_prompt="Combine the story, edits, and review into a final document.",
model_name="gpt-5.4"
)
moa_router = SwarmRouter(
swarm_type=SwarmType.MixtureOfAgents,
agents=agents,
aggregator_agent=aggregator, # MoA requires an aggregator
)
aggregated_output = moa_router.run(task)
print(f"Final Aggregated Output:\n{aggregated_output}\n")
SwarmRouter 是一个强大的工具,用于简化多智能体编排。它提供了一种一致且灵活的方式来部署不同的协作策略,使您能够用更少的代码构建更复杂的应用程序。
AutoSwarmBuilder: 自主智能体生成
AutoSwarmBuilder 会根据您的任务描述自动生成专用智能体及其工作流。只需描述您的需求,它便会创建一个包含详细提示词和最优智能体配置的完整多智能体系统。了解更多关于 AutoSwarmBuilder 的信息
from swarms import AutoSwarmBuilder
import json
# Initialize the AutoSwarmBuilder
swarm = AutoSwarmBuilder(
name="My Swarm",
description="A swarm of agents",
verbose=True,
max_loops=1,
return_agents=True,
model_name="gpt-5.4",
)
# Let the builder automatically create agents and workflows
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."
)
# The result contains the generated agents and their configurations
print(json.dumps(result, indent=4))
AutoSwarmBuilder 提供:
- 自动代理生成:根据任务需求创建专用代理
- 智能提示工程:为每个代理生成全面、详细的提示
- 最优工作流设计:确定最佳的代理交互和工作流结构
- 生产就绪配置:返回完全配置好、可直接部署的代理
- 灵活架构:支持多种蜂群类型和代理专业化
此功能非常适合快速原型开发、复杂任务分解以及无需手动配置即可创建专用代理团队。
MixtureOfAgents (MoA)
MixtureOfAgents 架构通过将任务并行地输入多个“专家”智能体来处理任务。随后,这些多样化的输出由一个聚合智能体进行综合,以生成最终的高质量结果。在此处了解更多
from swarms import Agent, MixtureOfAgents
# Define expert agents
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")
# Define the aggregator agent
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"
)
# Create the MoA swarm
moa_swarm = MixtureOfAgents(
agents=[financial_analyst, market_analyst, risk_analyst],
aggregator_agent=aggregator,
)
# Run the swarm
recommendation = moa_swarm.run("Should we invest in NVIDIA stock right now?")
print(recommendation)
GroupChat
GroupChat 是一个异步、自选择式的群聊。所有代理并行监听;对于每条广播消息,其他每个代理都会运行一个强制的 respond(score, message) 函数调用,以决定是否参与讨论,高于 threshold 的回复将被广播。当已发布 max_loops 条消息或 idle_timeout 秒内没有新消息到达时,聊天结束。没有回合顺序——多个代理可以同时响应同一条消息,而保持沉默的代理则继续沉默。
from swarms import Agent, GroupChat, RESPOND_TOOL
# Every agent MUST carry RESPOND_TOOL so the chat can ask it whether to speak.
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, # hard cap on total messages posted
threshold=0.5, # min decision score (0..1) to publish a reply
idle_timeout=8.0, # seconds of silence before stopping
)
result = chat.run("Let's discuss the societal impact of artificial intelligence.")
print(result)
HierarchicalSwarm
HierarchicalSwarm 实现了一种导演-工作者模式,其中中央导演智能体创建全面的计划,并将具体任务分配给专门的工作者智能体。导演评估结果并可在反馈循环中发布新指令,使其非常适合复杂的项目管理和团队协调场景。
from swarms import Agent, HierarchicalSwarm
# Define specialized worker agents
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"
)
# Create the hierarchical swarm with a director
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, # Allow for feedback and refinement
verbose=True
)
# Run the swarm on a complex marketing challenge
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)
The HierarchicalSwarm 擅长:
- 复杂项目管理:将大型任务分解为专门的子任务
- 团队协调:确保所有智能体朝着统一的目标努力
- 质量控制:Director 提供反馈和细化循环
- 可扩展的工作流:可根据需要轻松添加新的专门智能体
HeavySwarm
HeavySwarm 实现了一个受 X.AI 的 Grok 重型实现启发的复杂 5 阶段工作流。它使用专用智能体(Research、Analysis、Alternatives、Verification)通过智能问题生成、并行执行和综合,提供全面的任务分析。该架构擅长需要彻底调查和多种视角的复杂研究与分析任务。
from swarms import HeavySwarm
# Pip install swarms-tools
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)
HeavySwarm 提供:
-
五阶段分析:问题生成、研究、分析、备选方案与验证
-
专用智能体:每个阶段使用专为该阶段构建的智能体以获得最佳结果
-
全面覆盖:多视角与深入调查
-
实时仪表盘:可选的分析过程可视化
-
结构化输出:组织良好且可执行的结果
此架构非常适合财务分析、战略规划、研究报告以及任何需要深入、多维度分析的任务。了解更多关于 HeavySwarm
社交算法
社交算法 提供了一个灵活的框架,用于定义智能体之间的自定义通信模式。您可以上传任意社交算法作为可调用对象,以定义通信序列,从而让智能体以复杂的方式相互通信。了解更多关于社交算法的信息
from swarms import Agent, SocialAlgorithms
# Define a custom social algorithm
def research_analysis_synthesis_algorithm(agents, task, **kwargs):
# Agent 1 researches the topic
research_result = agents[0].run(f"Research: {task}")
# Agent 2 analyzes the research
analysis = agents[1].run(f"Analyze this research: {research_result}")
# Agent 3 synthesizes the findings
synthesis = agents[2].run(f"Synthesize: {research_result} + {analysis}")
return {
"research": research_result,
"analysis": analysis,
"synthesis": synthesis
}
# Create agents
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"
)
# Create social algorithm
social_alg = SocialAlgorithms(
name="Research-Analysis-Synthesis",
agents=[researcher, analyst, synthesizer],
social_algorithm=research_analysis_synthesis_algorithm,
verbose=True
)
# Run the algorithm
result = social_alg.run("The impact of AI on healthcare")
print(result.final_outputs)
非常适合实现复杂的多智能体工作流、协作式问题解决以及自定义通信协议。
智能体编排协议 (AOP)
智能体编排协议 (AOP) 是一个用于部署和管理智能体作为分布式服务的强大框架。AOP 使智能体能够通过标准化协议被发现、管理和执行,使其非常适合构建可扩展的多智能体系统。了解更多关于 AOP 的信息
from swarms import Agent, AOP
# Create specialized agents
research_agent = Agent(
agent_name="Research-Agent",
agent_description="Expert in research and data collection",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
tags=["research", "data-collection", "analysis"],
capabilities=["web-search", "data-gathering", "report-generation"],
role="researcher"
)
analysis_agent = Agent(
agent_name="Analysis-Agent",
agent_description="Expert in data analysis and insights",
model_name="anthropic/claude-sonnet-4-5",
max_loops=1,
tags=["analysis", "data-processing", "insights"],
capabilities=["statistical-analysis", "pattern-recognition", "visualization"],
role="analyst"
)
# Create AOP server
deployer = AOP(
server_name="ResearchCluster",
port=8000,
verbose=True
)
# Add agents to the server
deployer.add_agent(
agent=research_agent,
tool_name="research_tool",
tool_description="Research and data collection tool",
timeout=30,
max_retries=3
)
deployer.add_agent(
agent=analysis_agent,
tool_name="analysis_tool",
tool_description="Data analysis and insights tool",
timeout=30,
max_retries=3
)
# List all registered agents
print("Registered agents:", deployer.list_agents())
# Start the AOP server
deployer.run()
非常适合部署大规模多智能体系统。阅读完整的 AOP 文档
文档
完整文档位于 docs.swarms.world。以下是使用 Swarms 进行开发时最实用的资源——既适用于人类,也适用于 AI 编码助手。
| 资源 | 链接 | 用途 |
|---|---|---|
| 主文档 | docs.swarms.world | 指南、API 参考、教程 |
llms.txt(LLM 可摄取文档) | docs.swarms.world/llms.txt | 整个文档的单一机器可读索引,专为 LLM 和 AI IDE(Cursor、Claude Code 等)设计,可一次性获取 |
| MCP 集成指南 | docs.swarms.world/mcp | 如何将 Swarms Agent 连接到任何 Model Context Protocol 服务器,自动发现其工具,并从 swarm 中调用它们 |
| API 参考 | docs.swarms.world/api | Agent、SequentialWorkflow、ConcurrentWorkflow、AgentRearrange、GraphWorkflow、SwarmRouter 以及每种多智能体架构的逐类参考 |
| 环境设置 | docs.swarms.world/environment-setup | API 密钥、模型提供商和配置选项 |
给 AI 编码助手的提示: 将您的工具(Claude Code、Cursor、Windsurf、Continue 等)指向
https://docs.swarms.world/llms.txt。它将一次性拉取整个文档索引,并编写地道的 Swarms 代码,无需针对每个问题进行查找。
使用 Swarms 配合 AI 编码助手
该仓库在根目录附带了一个 CLAUDE.md —— 一份专注于指导 Claude Code、Cursor 及其他 AI 编码助手如何使用 Swarms 进行开发的指南。它涵盖了 Agent 原语、所有多智能体架构(SequentialWorkflow、ConcurrentWorkflow、AgentRearrange、GraphWorkflow、MixtureOfAgents、HierarchicalSwarm、SwarmRouter 等)、工具、流式处理、内存、MCP 集成,以及每种情况下应采用的模式。
将 CLAUDE.md(或将其符号链接为 AGENTS.md / .cursorrules)放入任何依赖 swarms 的项目中,你的助手就能在首次尝试时写出地道的 Swarms 代码——无需额外的提示词。
功能
Swarms 提供了一个全面的、企业级的多智能体基础设施平台,专为生产规模部署以及与现有系统的无缝集成而设计。在此了解更多关于 swarms 功能集的信息
| 类别 | 特性 | 优势 |
|---|---|---|
| 企业架构 | • 生产就绪基础设施 • 高可用性系统 • 模块化微服务设计 • 全面可观测性 • 向后兼容性 | • 99.9%+ 正常运行时间保证 • 降低运维开销 • 无缝遗留系统集成 • 增强系统监控 • 无风险迁移路径 |
| 多智能体编排 | • 分层智能体集群 • 并行处理流水线 • 顺序工作流编排 • 基于图的智能体网络 • 动态智能体组合 • 智能体注册表管理 | • 复杂业务流程自动化 • 可扩展的任务分发 • 灵活的工作流适应 • 优化的资源利用率 • 集中式智能体治理 • 企业级智能体生命周期管理 |
| 企业集成 | • 多模型提供商支持 • 自定义智能体开发框架 • 广泛的企业工具库 • 多种记忆系统 • 与 LangChain、AutoGen、CrewAI 的向后兼容性 • 标准化 API 接口 | • 供应商无关架构 • 自定义解决方案开发 • 扩展功能集成 • 增强的知识管理 • 无缝框架迁移 • 降低集成复杂度 |
| 企业级可扩展性 | • 并发多智能体处理 • 智能资源管理 • 负载均衡与自动扩缩容 • 水平扩展能力 • 性能优化 • 容量规划工具 | • 高吞吐量处理 • 高性价比资源利用 • 基于需求的弹性扩缩容 • 线性性能扩展 • 优化的响应时间 • 可预测的增长规划 |
| 开发者体验 | • 直观的企业级 API • 全面的文档 • 活跃的企业社区 • CLI 与 SDK 工具 • IDE 集成支持 • 代码生成模板 | • 加速开发周期 • 降低学习曲线 • 专家社区支持 • 快速部署能力 • 提升开发者生产力 • 标准化的开发模式 |
支持的协议与集成
Swarms 无缝集成行业标准协议和开放规范,为工具集成、支付处理、分布式智能体编排和模型互操作性解锁强大功能。
| 协议 | 描述 | 文档 |
|---|---|---|
| MCP (Model Context Protocol) | 用于 AI 代理通过 MCP 服务器与外部工具和服务交互的标准化协议。支持动态工具发现和执行。 | MCP 集成指南 |
| X402 | 用于 API 端点的加密货币支付协议。支持通过按使用量付费模式对代理进行货币化。 | X402 快速入门 |
| AOP (Agent Orchestration Protocol) | 用于将代理部署和管理为分布式服务的框架。支持通过标准化协议进行代理发现、管理和执行。 | AOP 参考 |
| Swarms Marketplace | 用于发现和共享生产就绪提示词、代理和工具的平台。支持从市场自动加载提示词,并直接从代码发布您自己的提示词。 | 市场教程 |
| Open Responses | 基于 OpenAI Responses API 的多提供商、可互操作 LLM 接口的开源规范和生态系统。提供统一的模式和工具,用于调用语言模型、流式传输结果以及组合代理工作流——独立于提供商。 | Open Responses 网站 |
| Agent Skills | 由 Anthropic 推出的轻量级、基于 Markdown 的格式,用于定义模块化、可复用的 Agent 能力。通过从简单的 SKILL.md 文件加载技能定义,无需修改代码即可实现 Agent 的专门化。 | Agent Skills Documentation |
示例
探索全面的示例和教程,学习如何有效使用 Swarms HERE
为 Swarms 做贡献
Swarms 是一个开源、社区驱动的框架,旨在通过为部署和编排数百万个智能体提供稳健的基础设施,来加速实现一个完全自主的世界。通过贡献,你可以助力多智能体 AI 的发展,与充满热情的同行协作,塑造智能体经济,并提升你的专业技能。
了解更多关于你如何在我们 贡献者指南 中产生有意义影响的信息。
如何贡献
我们让开始贡献变得轻而易举。以下是你可以提供帮助的方式:
-
寻找要解决的问题: 最好的开始方式是访问我们的 贡献项目看板。寻找标记为
good first issue的问题——这些是专门为新贡献者挑选的。 -
报告 Bug 或请求功能: 有新想法或发现某些功能运行不正常?我们很乐意听取你的意见。请在我们的 GitHub Issues 页面 提交 Bug 报告或功能请求。
-
了解我们的工作流和标准: 在提交你的工作之前,请查阅我们完整的 贡献指南。为了帮助维护代码质量,我们还鼓励你阅读我们的 代码整洁 指南。
-
加入讨论: 要参与路线图讨论并与其他开发者建立联系,请加入我们在 Discord 上的社区。
感谢我们的贡献者
感谢你对 swarms 的贡献。你的工作得到了极大的赞赏和认可。
我们正在招聘
Swarms 正在招聘。我们正在构建自主智能体世界的基础设施,并寻找希望在多智能体 AI 前沿交付成果的工程师、研究人员和运营人员。
- 开放职位: swarms.ai/hiring
- 联系我们: 发送邮件至 kye@swarms.world 以了解更多
加入 Discord
加入数千名智能体构建者和 AI 工程师,进入 Swarms Discord,获取技术支持、项目展示、协作机会以及最新的 swarms 生态系统更新。
加入 Swarms 社区!
加入我们的智能体工程师和研究人员社区,获取技术支持、前沿更新以及独家访问世界一流的智能体工程洞察!
| 平台 | 描述 | 链接 |
|---|---|---|
| Documentation | 官方文档和指南 | docs.swarms.world |
| Blog | 最新更新和技术文章 | Medium |
| Discord | 实时聊天和社区支持 | Join Discord |
| 最新新闻和公告 | @swarms_corp | |
| 专业网络和更新 | The Swarm Corporation | |
| YouTube | 教程和演示 | Swarms Channel |
| Events | 加入我们的社区活动 | Sign up here |
| Onboarding Session | 与 Swarms 的创建者和主要维护者 Kye Gomez 一起完成入职 | Book Session |
引用
如果你在研究中使用 swarms,请通过引用 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}
许可证
Swarms 采用 Apache License 2.0 授权。在此了解更多