跳到正文
Skillpedia
智能体7.3k · #13288

swarms

它能做什么

这个技能教智能体如何用 Swarms 框架为 AI 智能体编写代码。适合用 Python 构建智能体、工具和多智能体工作流的开发者。

适用场景

  • ✓你想用 Swarms 在 Python 中构建一个 AI 智能体的时候。
  • ✓你想让多个智能体按照设定的工作流协同工作的时候。
  • ✓你的 Swarms 代码出错,想让人审核或修复它的时候。

技能链接

https://github.com/kyegomez/swarms/blob/master/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/kyegomez/swarms/blob/master/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请用 Python 构建一个由三个 Swarms 智能体组成的团队,分别负责研究、撰写和审核一份简短报告。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会使用框架的 Agent 类及其现成的团队结构,并遵循框架的规则和示例。当某个细节与已安装的版本不一致时,它会检查当前文档。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Swarms

Swarms is a multi-agent orchestration framework. Everything is built from one primitive — Agent — which multi-agent structures compose. This document is verified against swarms v14.0.0.

Live documentation

This skill can lag the library. When a signature here disagrees with the installed version, check the current docs:

  • Docs MCP server, no key: https://docs.swarms.world/mcp (claude mcp add --transport http swarms-docs https://docs.swarms.world/mcp)
  • Marketplace MCP server, Swarms API key for calls: https://swarms.world/mcp
  • Plain-text docs: llms.txt (index), llms-full.txt (every page)

Golden rules

  1. Import from the top level: from swarms import Agent, never from swarms.structs.agent import Agent. The one common exception is PlannerWorkerSwarm (see below).
  2. Every agent needs a unique agent_name — memory files and swarm routing key on it.
  3. Default to max_loops=1. Use a specific integer for production. Use "auto" only for genuinely open-ended work.
  4. Pass tools=None, not tools=[]. An empty list breaks schema generation.
  5. Check examples/ — 586 runnable examples live there. One is probably close to what you need.
  6. Never set streaming_on=True and streaming_callback together. Pick one.

Setup

pip install -U swarms

Set the key for whichever provider you use — any LiteLLM model string works:

export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GROQ_API_KEY="..."
export WORKSPACE_DIR="agent_workspace"   # where agent state and memory land

Part 1 — The Agent

from swarms import Agent

agent = Agent(
    agent_name="Analyst",
    agent_description="Analyzes market data and produces summaries.",
    system_prompt="You are a precise financial analyst.",
    model_name="gpt-5.4",
    max_loops=1,
)

result = agent.run("Summarize the state of the semiconductor market.")

Agent.__init__ accepts 90+ parameters. These are the ones that matter:

Parameter Type Default Purpose
agent_name str "swarm-worker-01" Unique identity; keys memory + routing
agent_description str generic How orchestrators decide to route to it
system_prompt str built-in Persona and instructions
model_name str "gpt-5.4" Any LiteLLM model string
max_loops int | "auto" 1 Iterations, or autonomous mode
tools list[Callable] None Python functions the agent may call
temperature float 0.5 Sampling temperature
max_tokens int model max Output cap per call
top_p float None Nucleus sampling
context_length int None Token budget; triggers compression at 90%
output_type str "str-all-except-first" Return shape — see below
streaming_on bool False Stream tokens to stdout
streaming_callback Callable None Stream tokens to your function
interactive bool False REPL — prompts the user each loop
verbose bool False Debug logging
print_on bool True Print the final output
autosave bool False Persist agent state after each run
retry_attempts int 3 LLM call retries
reasoning_effort str None minimal/low/medium/high/xhigh/ultra/max/none
thinking_tokens int 1024 Extended thinking budget (Claude)
mcp_url / mcp_urls str / list[str] None MCP servers to load tools from
handoffs list[Agent] None Agents this one may delegate to
persistent_memory bool False Read/write MEMORY.md across restarts
context_compression bool True Auto-summarize near the context limit
plan_enabled bool False Plan before executing
mode str "standard" "standard", "fast", "interactive"
fallback_models list[str] None Models to try if the primary fails

output_type options: "str", "list", "dict", "json", "yaml", "final", "last", "all", "str-all-except-first", "dict-all-except-first", "dict-final", "list-final".

Running

agent.run(task="...")                          # standard
agent.run(task="...", img="chart.png")         # one
常见问题

我需要是 Python 专家吗?

了解一些 Python 会有帮助,因为代码是用 Python 编写的。大部分编码工作由智能体完成。

代码会与最新的库版本相符吗?

技能说明,库的更新可能快于指南,因此当细节不一致时,智能体应检查当前文档。

它也涵盖单个智能体吗?

涵盖。每个团队都由一种基础智能体类型构建,因此同样的思路也适用于单个智能体。

详情

作者的原始描述

Build agents and multi-agent systems with the Swarms framework — the Agent class, tools, autonomous loops, memory, and the 15+ multi-agent architectures (SequentialWorkflow, ConcurrentWorkflow, GraphWorkflow, HierarchicalSwarm, SwarmRouter, and more). Use whenever writing, reviewing, or debugging code that imports `swarms`.

repo: kyegomez/swarms

热度

GitHub 星标
7.3k
排名
#13288
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能