Chuyển đến nội dung
Skillpedia
Agent7.3k · #13288

swarms

Skill này làm gì

Skill này dạy agent cách viết code với framework Swarms cho agent AI. Dành cho lập trình viên xây dựng agent, công cụ và luồng làm việc nhiều agent bằng Python.

Khi nào nên dùng

  • ✓Khi bạn muốn xây một agent AI bằng Python với Swarms.
  • ✓Khi bạn muốn nhiều agent cùng làm việc trong một luồng cố định.
  • ✓Khi code Swarms của bạn bị lỗi và bạn muốn nó được xem lại hoặc sửa.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/kyegomez/swarms/blob/master/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Xây một đội ba agent Swarms bằng Python: một agent nghiên cứu, một agent viết và một agent rà soát một báo cáo ngắn.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent dùng lớp Agent của framework và các cấu trúc đội có sẵn, theo quy tắc và ví dụ của framework. Khi một chi tiết không khớp với phiên bản đã cài, nó kiểm tra tài liệu hiện tại.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Tôi có cần là chuyên gia Python không?

Có chút kiến thức Python sẽ giúp ích, vì code được viết bằng Python. Agent làm phần lớn việc viết code.

Code có khớp với phiên bản thư viện mới nhất không?

Skill nói thư viện có thể thay đổi nhanh hơn hướng dẫn, nên agent nên kiểm tra tài liệu hiện tại khi chi tiết khác nhau.

Nó có bao gồm agent đơn không?

Có. Mọi đội đều được xây từ một loại agent cơ bản, nên các ý tưởng áp dụng cho một agent đơn.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
7.3k
Vị trí xếp hạng
#13288
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Skill tương tự