본문으로 건너뛰기
cccskills
무료GitHub에 공개

swarms

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`.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구OpenAI
설치 방법 보기

포함된 파일(200)

  • SKILL.md21.7 KB
  • .dockerignore61 B
  • .env.example997 B
  • .github/action.yml1.1 KB
  • .github/CODEOWNERS2.2 KB
  • .github/dependabot.yml367 B
  • .github/FUNDING.yml640 B
  • .github/ISSUE_TEMPLATE/bug_report.md548 B
  • .github/ISSUE_TEMPLATE/feature_request.md603 B
  • .github/labeler.yml851 B
  • .github/PULL_REQUEST_TEMPLATE.md1.4 KB
  • .github/workflows/dependency-review.yml1.7 KB
  • .github/workflows/label-ai-generated.yml3.8 KB
  • .github/workflows/label.yml546 B
  • .github/workflows/lint.yml800 B
  • .github/workflows/pyre.yml1.2 KB
  • .github/workflows/python-package.yml1.5 KB
  • .github/workflows/RELEASE.yml1.2 KB
  • .github/workflows/stale.yml1.9 KB
  • .github/workflows/test-main-features.yml4.5 KB
  • .github/workflows/tests.yml579 B
  • .github/workflows/welcome.yml583 B
  • .gitignore7.5 KB
  • auto_loop_streaming_example.py932 B
  • CITATION.cff338 B
  • CLAUDE.md36.5 KB
  • CODE_OF_CONDUCT.md5.1 KB
  • CONTRIBUTING.md8.5 KB
  • Dockerfile1.1 KB
  • example.py1.4 KB
  • examples/changelogs/880_update_changelog_examples/01_marketplace_prompt_fetching.py519 B
  • examples/changelogs/880_update_changelog_examples/02_round_robin_swarm_routing.py906 B
  • examples/changelogs/880_update_changelog_examples/03_graph_workflow_rustworkx.py1.2 KB
  • examples/changelogs/880_update_changelog_examples/04_agent_rearrange.py1.0 KB
  • examples/changelogs/880_update_changelog_examples/05_nested_swarms.py1.0 KB
  • examples/changelogs/880_update_changelog_examples/06_spreadsheet_swarm.py1.2 KB
  • examples/changelogs/880_update_changelog_examples/07_model_router.py643 B
  • examples/changelogs/880_update_changelog_examples/08_self_moa_seq.py568 B
  • examples/changelogs/880_update_changelog_examples/09_single_voice_agent.py692 B
  • examples/changelogs/880_update_changelog_examples/10_multi_agent_voice_debate.py1.4 KB
  • examples/changelogs/880_update_changelog_examples/11_hierarchical_voice_swarm.py2.1 KB
  • examples/changelogs/880_update_changelog_examples/12_debate_with_judge.py413 B
  • examples/changelogs/880_update_changelog_examples/13_council_as_judge.py667 B
  • examples/changelogs/880_update_changelog_examples/14_swarm_router_round_robin.py949 B
  • examples/changelogs/880_update_changelog_examples/15_graph_workflow_batch_agents.py1.5 KB
  • examples/changelogs/880_update_changelog_examples/autosaving_example.py469 B
  • examples/changelogs/880_update_changelog_examples/README.md12.0 KB
  • examples/changelogs/v11_update/advisor_swarm_basic.py399 B
  • examples/changelogs/v11_update/advisor_swarm_custom_agents.py641 B
  • examples/changelogs/v11_update/agent_rearrange_batch_run.py438 B
  • examples/changelogs/v11_update/agent_rearrange_repeated_flow.py540 B
  • examples/changelogs/v11_update/conversation_cache_example.py395 B
  • examples/changelogs/v11_update/env_loading_example.py119 B
  • examples/changelogs/v11_update/graph_workflow_checkpoint.py364 B
  • examples/changelogs/v11_update/graph_workflow_serialization.py513 B
  • examples/changelogs/v11_update/heavy_swarm_16_agents.py293 B
  • examples/changelogs/v11_update/heavy_swarm_grok_basic.py254 B
  • examples/changelogs/v11_update/heavy_swarm_grok_router.py206 B
  • examples/changelogs/v11_update/hierarchical_swarm_example.py664 B
  • examples/changelogs/v11_update/planner_generator_evaluator_basic.py465 B
  • examples/changelogs/v11_update/planner_generator_evaluator_with_tools.py323 B
  • examples/changelogs/v11_update/planner_worker_swarm_basic.py448 B
  • examples/changelogs/v11_update/planner_worker_task_schema.py437 B
  • examples/changelogs/v11_update/sequential_workflow_drift_detection.py650 B
  • examples/changelogs/v11_update/v11_blog.md23.0 KB
  • examples/changelogs/v11_update/v11_changelog.md34.1 KB
  • examples/changelogs/v11_update/v11.md14.5 KB
  • examples/changelogs/v12_update/01_persistent_memory.py1.3 KB
  • examples/changelogs/v12_update/02_context_compression.py1.3 KB
  • examples/changelogs/v12_update/03_grep_tool_autonomous_loop.py1.0 KB
  • examples/changelogs/v12_update/04_conversation_memory_compact.py2.2 KB
  • examples/changelogs/v12_update/05_graph_workflow_callbacks.py2.0 KB
  • examples/changelogs/v12_update/06_arun_stream.py2.0 KB
  • examples/changelogs/v12_update/07_interactive_mode.py583 B
  • examples/changelogs/v12_update/article.md11.6 KB
  • examples/changelogs/v12_update/byzantine_consensus.py12.7 KB
  • examples/changelogs/v12_update/changelog_v12_organized.md10.6 KB
  • examples/changelogs/v12_update/changelog_v12.md8.6 KB
  • examples/changelogs/v13/agent_lookup_helpers_example.py1.3 KB
  • examples/changelogs/v13/agent_rearrange_flow_example.py1.0 KB
  • examples/changelogs/v13/agent_tools_default_example.py534 B
  • examples/changelogs/v13/CHANGELOG.md18.7 KB
  • examples/changelogs/v13/cli_examples.sh277 B
  • examples/changelogs/v13/graph_workflow_composition_example.py1.2 KB
  • examples/changelogs/v13/groupchat_self_selecting_example.py1.1 KB
  • examples/changelogs/v13/heavy_swarm_variant_example.py320 B
  • examples/changelogs/v13/README.md1.7 KB
  • examples/changelogs/v13/round_robin_rotation_example.py682 B
  • examples/changelogs/v13/sequential_workflow_streaming_example.py1.1 KB
  • examples/changelogs/v13/swarm_router_groupchat_example.py934 B
  • examples/changelogs/v14-zena/01_opentelemetry_tracing.py811 B
  • examples/changelogs/v14-zena/02_instrument_custom_harness.py1.2 KB
  • examples/changelogs/v14-zena/03_mcp_manager.py1.5 KB
  • examples/changelogs/v14-zena/04_auto_agent_builder.py1.4 KB
  • examples/changelogs/v14-zena/05_auction_swarm.py1.1 KB
  • examples/changelogs/v14-zena/06_groupchat_turn_based.py1.3 KB
  • examples/changelogs/v14-zena/07_hierarchical_swarm_recovery.py1.3 KB
  • examples/changelogs/v14-zena/09_class_to_pydantic.py1.1 KB
  • examples/changelogs/v14-zena/10_concurrent_workflow_on_error.py794 B
  • examples/changelogs/v14-zena/11_graph_workflow.py961 B
  • examples/changelogs/v14-zena/12_thread_pool_sizing.py904 B
  • examples/changelogs/v14-zena/13_agent_loader_csv.py431 B
  • examples/changelogs/v14-zena/README.md2.8 KB
  • examples/changelogs/v9_examples/autonomous_looper.py491 B
  • examples/changelogs/v9_examples/example_autonomous_looper_tools.py2.8 KB
  • examples/changelogs/v9_examples/example_sub_agents.py989 B
  • examples/cli/01_setup_check.sh108 B
  • examples/cli/02_onboarding.sh110 B
  • examples/cli/03_get_api_key.sh102 B
  • examples/cli/04_check_login.sh100 B
  • examples/cli/05_create_agent.sh316 B
  • examples/cli/06_run_agents_yaml.sh147 B
  • examples/cli/07_load_markdown.sh140 B
  • examples/cli/08_llm_council.sh184 B
  • examples/cli/09_heavy_swarm.sh183 B
  • examples/cli/10_autoswarm.sh155 B
  • examples/cli/11_features.sh100 B
  • examples/cli/12_help.sh98 B
  • examples/cli/13_auto_upgrade.sh109 B
  • examples/cli/14_book_call.sh95 B
  • examples/cli/README.md4.5 KB
  • examples/cli/research_agent_example.sh674 B
  • examples/cli/run_all_examples.sh144 B
  • examples/decision_models/calibrated_ensemble_judge.py6.4 KB
  • examples/decision_models/debate_referee_early_stop.py4.2 KB
  • examples/decision_models/decision_model_agent_router.py2.6 KB
  • examples/decision_models/decision_screening_funnel.py11.2 KB
  • examples/decision_models/get_decision_models_example.py1.2 KB
  • examples/decision_models/guarded_group_chat.py5.7 KB
  • examples/decision_models/openai_decisions.py2.3 KB
  • examples/decision_models/simple_openai.py1.2 KB
  • examples/decision_models/system_one_director_swarm.py6.3 KB
  • examples/decision_models/typesafe_ticket_triage.py1.9 KB
  • examples/guides/840_update/agent_rearrange_concurrent_example.py4.0 KB
  • examples/guides/840_update/auto_swarm_builder_example.py562 B
  • examples/guides/840_update/fallback_example.py568 B
  • examples/guides/840_update/README.md661 B
  • examples/guides/850_workshop/moa_seq_example.py484 B
  • examples/guides/850_workshop/peer_review_example.py2.6 KB
  • examples/guides/850_workshop/README.md631 B
  • examples/guides/850_workshop/test_agent_concurrent.py1004 B
  • examples/guides/agentsh_implementation/agentsh.py49.7 KB
  • examples/guides/agentsh_implementation/README.md9.7 KB
  • examples/guides/changelog_890/01_dynamic_skills_loader.py1.2 KB
  • examples/guides/changelog_890/02_autonomous_agent_loop.py3.0 KB
  • examples/guides/changelog_890/03_agent_handoffs.py1.2 KB
  • examples/guides/changelog_890/04_api_key_validation.py1.1 KB
  • examples/guides/changelog_890/05_max_loops_parameter.py1.3 KB
  • examples/guides/changelog_890/06_multi_tool_agent_tutorial.py2.6 KB
  • examples/guides/changelog_890/07_hierarchical_voice_agent.py2.3 KB
  • examples/guides/changelog_890/08_agent_rearrange_patterns.py1.4 KB
  • examples/guides/changelog_890/README.md5.2 KB
  • examples/guides/demos/agent_with_fluidapi.py3.1 KB
  • examples/guides/demos/apps/hiring_swarm.py12.9 KB
  • examples/guides/demos/apps/smart_database_swarm.py35.7 KB
  • examples/guides/demos/chart_swarm.py10.8 KB
  • examples/guides/demos/crypto/dao_swarm.py11.1 KB
  • examples/guides/demos/crypto/ethchain_agent.py10.1 KB
  • examples/guides/demos/crypto/htx_swarm.py9.5 KB
  • examples/guides/demos/crypto/swarms_coin_agent.py6.4 KB
  • examples/guides/demos/crypto/swarms_coin_multimarket.py12.6 KB
  • examples/guides/demos/cuda_swarm.py14.9 KB
  • examples/guides/demos/finance/sentiment_news_analysis.py7.4 KB
  • examples/guides/demos/hackathon_feb16/fraud.py10.6 KB
  • examples/guides/demos/hackathon_feb16/sarasowti.py8.7 KB
  • examples/guides/demos/insurance/insurance_swarm.py10.7 KB
  • examples/guides/demos/legal/legal_swarm.py15.3 KB
  • examples/guides/demos/medical/health_privacy_swarm_two.py9.6 KB
  • examples/guides/demos/medical/health_privacy_swarm.py9.1 KB
  • examples/guides/demos/medical/medical_analysis_agent_rearrange.md12.7 KB
  • examples/guides/demos/medical/medical_coder_agent.py7.3 KB
  • examples/guides/demos/medical/medical_coding_report.md16.7 KB
  • examples/guides/demos/medical/medical_diagnosis_report.md16.0 KB
  • examples/guides/demos/medical/new_medical_rearrange.py5.7 KB
  • examples/guides/demos/medical/ollama_demo.py7.3 KB
  • examples/guides/demos/medical/rearrange_video_examples/reports/medical_analysis_agent_rearrange.md12.1 KB
  • examples/guides/demos/medical/rearrange_video_examples/reports/vc_document_analysis.md19.1 KB
  • examples/guides/demos/medical/rearrange_video_examples/term_sheet_swarm.py6.9 KB
  • examples/guides/demos/news_aggregator_summarizer.py3.0 KB
  • examples/guides/demos/privacy_building.py8.8 KB
  • examples/guides/demos/README.md4.1 KB
  • examples/guides/demos/real_estate/morgtate_swarm.py21.6 KB
  • examples/guides/demos/real_estate/README_realtor.md1.1 KB
  • examples/guides/demos/real_estate/real_estate_agent.py9.9 KB
  • examples/guides/demos/real_estate/realtor_agent.py4.6 KB
  • examples/guides/demos/science/materials_science_agents.py12.1 KB
  • examples/guides/demos/science/open_scientist.py22.2 KB
  • examples/guides/demos/science/paper_idea_agent.py2.4 KB
  • examples/guides/demos/science/paper_idea_profile.py3.7 KB
  • examples/guides/demos/spike/agent_rearrange_test.py7.8 KB
  • examples/guides/demos/spike/function_caller_example.py1.4 KB
  • examples/guides/demos/spike/memory.py4.1 KB
  • examples/guides/demos/spike/spike.zip7.2 KB
  • examples/guides/demos/spike/test.py7.6 KB
  • examples/guides/demos/synthetic_data/profession_sim/convert_json_to_csv.py555 B
  • examples/guides/demos/synthetic_data/profession_sim/data.csv260.8 KB
  • examples/guides/demos/synthetic_data/profession_sim/format_prompt.py2.0 KB
  • examples/guides/demos/synthetic_data/profession_sim/profession_persona_generator.py42.2 KB
  • examples/guides/demos/synthetic_data/profession_sim/profession_personas_new_10.csv158.6 KB
  • examples/guides/demos/synthetic_data/profession_sim/profession_personas_new_10.progress_neee.json163.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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.

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:

ParameterTypeDefaultPurpose
agent_namestr"swarm-worker-01"Unique identity; keys memory + routing
agent_descriptionstrgenericHow orchestrators decide to route to it
system_promptstrbuilt-inPersona and instructions
model_namestr"gpt-5.4"Any LiteLLM model string
max_loopsint | "auto"1Iterations, or autonomous mode
toolslist[Callable]NonePython functions the agent may call
temperaturefloat0.5Sampling temperature
max_tokensintmodel maxOutput cap per call
top_pfloatNoneNucleus sampling
context_lengthintNoneToken budget; triggers compression at 90%
output_typestr"str-all-except-first"Return shape — see below
streaming_onboolFalseStream tokens to stdout
streaming_callbackCallableNoneStream tokens to your function
interactiveboolFalseREPL — prompts the user each loop
verboseboolFalseDebug logging
print_onboolTruePrint the final output
autosaveboolFalsePersist agent state after each run
retry_attemptsint3LLM call retries
reasoning_effortstrNoneminimal/low/medium/high/xhigh/ultra/max/none
thinking_tokensint1024Extended thinking budget (Claude)
mcp_url / mcp_urlsstr / list[str]NoneMCP servers to load tools from
handoffslist[Agent]NoneAgents this one may delegate to
persistent_memoryboolFalseRead/write MEMORY.md across restarts
context_compressionboolTrueAuto-summarize near the context limit
plan_enabledboolFalsePlan before executing
modestr"standard""standard", "fast", "interactive"
fallback_modelslist[str]NoneModels to try if the primary fails

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

Running

agent.run(task="...")                          # standard
agent.run(task="...", img="chart.png")         # one image
agent.run(task="...", imgs=["a.png", "b.png"]) # several images
agent.run(task="...", n=3)                     # 3 independent samples
await agent.arun("...")                        # async

Agent.run signature: run(task=None, img=None, imgs=None, correct_answer=None, streaming_callback=None, n=1).

Streaming

# To stdout
agent = Agent(agent_name="Writer", model_name="gpt-5.4", streaming_on=True)
agent.run("Write a haiku about distributed systems.")

# To a callback (do NOT combine with streaming_on)
def on_token(token: str) -> None:
    print(token, end="", flush=True)

agent = Agent(agent_name="Writer", model_name="gpt-5.4", streaming_callback=on_token)
agent.run("Write a haiku.")

# Async streaming
async for token in agent.arun_stream("Explain async/await."):
    print(token, end="", flush=True)

Part 2 — Tools

Any Python function with type hints and a docstring becomes a tool. The framework generates the OpenAI function schema automatically — the docstring is the tool description the model reads, so write it for the model.

from swarms import Agent

def get_stock_price(ticker: str) -> str:
    """Fetch the current stock price for a ticker symbol.

    Args:
        ticker: Stock ticker symbol, e.g. 'AAPL'.

    Returns:
        The current price as a formatted string.
    """
    import yfinance as yf
    return f"{ticker}: ${yf.Ticker(ticker).fast_info['last_price']:.2f}"

agent = Agent(
    agent_name="StockAnalyst",
    model_name="gpt-5.4",
    tools=[get_stock_price],
    max_loops=3,          # needs > 1 so it can act on the tool result
)
agent.run("What are Apple and Microsoft trading at?")

max_loops must exceed 1 for tool use — loop 1 calls the tool, loop 2 uses the result.

Related knobs: tool_call_summary=True (summarize tool output), show_tool_execution_output=True (print raw returns), tool_retry_attempts (retries on tool failure).

MCP servers

agent = Agent(
    agent_name="MCPAgent",
    model_name="gpt-5.4",
    mcp_url="http://localhost:8000/sse",
    # or: mcp_urls=["http://localhost:8000/sse", "http://localhost:8001/sse"]
    max_loops=3,
)

Inspect what a server exposes before wiring it up:

from swarms.tools.mcp_manager import MCPManager

mgr = MCPManager(mcp_url="http://localhost:8000/sse")
print(mgr.list_tool_names())
schemas = mgr.get_tools()          # aget_tools() for the async form

Handoffs

Give an agent a roster it can delegate to. It receives a handoff_task tool automatically.

triage = Agent(
    agent_name="Triage",
    model_name="gpt-5.4",
    handoffs=[billing_agent, technical_agent, refunds_agent],
    max_loops=3,
)
triage.run("My invoice is wrong and the app won't load.")

Part 3 — Autonomous mode (max_loops="auto")

The agent runs plan → execute → reflect until it decides it is finished, with 16 built-in tools available:

GroupTools
Planningcreate_plan, think, subtask_done, complete_task, respond_to_user
Filescreate_file, update_file, read_file, list_directory, delete_file
Systemrun_bash, grep
Delegationcreate_sub_agent, assign_task, check_sub_agent_status, cancel_sub_agent_tasks
agent = Agent(
    agent_name="Researcher",
    model_name="gpt-5.4",
    max_loops="auto",
    tools=[search_web],           # your tools stack on top of the built-ins
    persistent_memory=True,
    context_compression=True,
    context_length=32000,
)
agent.run("Research the top 5 vector databases and write compare.md")

Restrict the built-in set with selected_tools (default "all"):

agent = Agent(
    agent_name="ReadOnly",
    max_loops="auto",
    selected_tools=["create_plan", "think", "read_file", "grep", "complete_task"],
)

Inspect the full list at runtime with agent.get_all_selected_tools().

⚠️ run_bash and delete_file are real. In autonomous mode the agent can modify and delete files and execute shell commands. Scope selected_tools and set WORKSPACE_DIR deliberately.


Part 4 — Memory and conversation

Persistent memory

persistent_memory=True reads {WORKSPACE_DIR}/agents/{agent_name}/MEMORY.md on startup and appends to it each response. It is off by default — set it in every process that should share the memory.

agent = Agent(agent_name="ProjectAssistant", model_name="gpt-5.4", persistent_memory=True)
agent.run("My project is called Helios. Remember that.")

# Later process, same agent_name and the flag set again → it remembers.

Context compression

context_compression=True (default) fires at 90% of context_length, summarizing history in place so long sessions never hit the wall. Leave it on for anything long-running.

Conversation

from swarms import Conversation

conv = Conversation(
    name="my-conversation",     # note: `name`, not `agent_name`
    system_prompt="You are helpful.",
    time_enabled=True,
    token_count=True,
)
conv.add("user", "What is 2+2?")
conv.add("assistant", "4.")

conv.return_history_as_string()
conv.search("2+2")
conv.compact(summary="User asked arithmetic. Answer: 4.")   # archives, then collapses
conv.save_as_json("conv.json")

Part 5 — Multi-agent architectures

Choosing one

SituationUse
Single taskAgent
Linear A→B→CSequentialWorkflow
Same task, many agents at onceConcurrentWorkflow
Custom mix of sequential + parallelAgentRearrange
Dependency graph / fan-out-fan-inGraphWorkflow
Many models, one synthesized answerMixtureOfAgents
Manager delegates to specialistsHierarchicalSwarm
Open discussionGroupChat
Discrete decision by consensusMajorityVoting
Quality-critical evaluationCouncilAsAJudge
Structured adversarial debateDebateWithJudge
Deep multi-stage researchHeavySwarm
Route each task to the best agentMultiAgentRouter
Plan then execute with workersPlannerWorkerSwarm
Don't know yetSwarmRouter(swarm_type="auto") or AutoSwarmBuilder

SequentialWorkflow

Each agent's output becomes the next agent's context.

from swarms import Agent, SequentialWorkflow

pipeline = SequentialWorkflow(
    agents=[researcher, analyst, writer],
    max_loops=1,
    output_type="dict",
)
pipeline.run("Analyze how rate hikes affect tech stocks.")

Options: team_awareness=True (agents see the roster), multi_agent_collab_prompt=True, drift_detection=True.

ConcurrentWorkflow

All agents run the same task in parallel.

from swarms import Agent, ConcurrentWorkflow

workflow = ConcurrentWorkflow(
    agents=agents,
    max_workers=5,
    show_dashboard=True,
    on_error="store",          # or "raise"
)
workflow.run("List 10 use cases for multi-agent AI.")

AgentRearrange — flow DSL

from swarms import Agent, AgentRearrange

pipeline = AgentRearrange(
    agents=[planner, coder, reviewer, tester],
    flow="Planner -> Coder -> Reviewer, Tester",
    max_loops=1,
)
pipeline.run("Build an email validator.")
  • A -> B — sequential, B receives A's output
  • A, B — concurrent, same input
  • A -> B, C -> D — A, then B and C in parallel, then D on their combined output

Every name in flow must match an agent_name in agents, or it fails at run time. There is no human-in-the-loop step — split into separate .run() calls and insert your own input() between them.

GraphWorkflow — DAG

Pass agents directly to add_node/add_edge; there is no need to wrap them in Node objects.

from swarms import Agent, GraphWorkflow

wf = GraphWorkflow(name="research-dag", max_loops=1)

for a in (ingestion, branch_a, branch_b, merger):
    wf.add_node(a)

wf.add_edge(ingestion, branch_a)      # fan out
wf.add_edge(ingestion, branch_b)
wf.add_edge(branch_a, merger)         # fan in
wf.add_edge(branch_b, merger)

wf.set_entry_points(["Ingestion"])
wf.set_end_points(["Merger"])

def on_done(node: str, result) -> None:
    print(f"[{node}] {len(str(result))} chars")

results = wf.run(task="Analyze this dataset two ways and merge.", on_node_complete=on_done)

add_node also accepts a nested GraphWorkflow. Other options: backend="networkx"|"rustworkx", max_parallel_nodes, checkpoint_dir, streaming_callback.

SwarmRouter — one entry point

Swap architectures without rewriting orchestration.

from swarms import Agent, SwarmRouter

router = SwarmRouter(agents=agents, swarm_type="SequentialWorkflow", max_loops=1)
router.run("Write a post about transformers.")

Valid swarm_type values — exactly these 16:

"AgentRearrange", "MixtureOfAgents", "SequentialWorkflow", "ConcurrentWorkflow", "GroupChat", "MultiAgentRouter", "HierarchicalSwarm", "MajorityVoting", "CouncilAsAJudge", "HeavySwarm", "BatchedGridWorkflow", "LLMCouncil", "DebateWithJudge", "RoundRobin", "PlannerWorkerSwarm", "auto".

"AutoSwarmBuilder" and "SpreadSheetSwarm" are not router types — use those classes directly. With swarm_type="AgentRearrange" you must also pass rearrange_flow.

MixtureOfAgents

Workers answer independently; an aggregator synthesizes. Best with diverse providers.

from swarms import Agent, MixtureOfAgents

moa = MixtureOfAgents(
    agents=[worker_gpt, worker_claude, worker_llama],
    aggregator_agent=aggregator,       # optional; falls back to aggregator_model_name
    layers=3,
    max_loops=1,
)
moa.run("Best practices for securing a Kubernetes cluster?")

HierarchicalSwarm

A director decomposes the task, delegates, and synthesizes results.

from swarms import Agent, HierarchicalSwarm

swarm = HierarchicalSwarm(
    agents=[data_worker, writing_worker, review_worker],
    director=director,            # optional; else built from director_model_name
    max_loops=2,
    planning_enabled=True,
    parallel_execution=True,
    director_feedback_on=True,
)
swarm.run("Produce a competitive analysis of the AI chip market.")

Also: agent_as_judge=True, max_agent_retries, max_reassignment_attempts, interactive=True.

GroupChat

Asynchronous and self-selecting — no rounds, no speaker-selection function. Every agent scores how much it wants to speak (0–1); replies above threshold are broadcast. Ends at max_loops messages or after idle_timeout seconds of silence.

from swarms import Agent, GroupChat

chat = GroupChat(
    agents=[optimist, pessimist, realist],   # at least 2 required
    max_loops=10,
    threshold=0.5,           # raise for a more selective room
    recency_penalty=0.3,     # discourages one agent dominating
    idle_timeout=8.0,
)
chat.run("Should we adopt AI for medical diagnosis?")

auto_equip=True (default) injects the required RESPOND_TOOL into every agent — you do not need to pass it yourself. Set auto_equip=False only if you attach RESPOND_TOOL manually via tools_list_dictionary.

MajorityVoting

Agents answer independently; a consensus agent picks the winner.

from swarms import Agent, MajorityVoting

mv = MajorityVoting(
    agents=voters,
    consensus_agent_model_name="gpt-5.4",
    max_loops=1,
)
mv.run("Python or Rust for a high-performance web server?")

CouncilAsAJudge

Evaluates a response across dimensions. It builds its own council from model names — it does not take an agents list or a judge agent.

from swarms import CouncilAsAJudge

council = CouncilAsAJudge(
    model_name="gpt-5.4",
    aggregation_model_name="gpt-5.4",
    random_model_name=True,
    max_loops=1,
)
council.run("Should we store biometric data on-device only?")

DebateWithJudge

from swarms import Agent, DebateWithJudge

debate = DebateWithJudge(
    pro_agent=pro,
    con_agent=con,
    judge_agent=judge,
    max_loops=3,          # rounds
)
debate.run("Motion: open-source LLMs will surpass closed-source by 2027.")

preset_agents=True generates pro/con/judge for you from model_name. The kwargs are pro_agent/con_agent/judge_agent — not agents=[...] plus judge=.

HeavySwarm

Deep multi-stage analysis. Configured by model names, not by an agents list.

from swarms import HeavySwarm

swarm = HeavySwarm(
    question_agent_model_name="gpt-5.4",
    worker_model_name="gpt-5.4",
    max_loops=1,
    timeout=900,
    show_dashboard=True,
    worker_tools=[search_web],
)
swarm.run("Analyze the implications of AGI on global labour markets.")

PlannerWorkerSwarm

A planner decomposes the task and workers execute; a judge checks completion each cycle. Not exported at the top level:

from swarms.structs.planner_worker_swarm import PlannerWorkerSwarm

swarm = PlannerWorkerSwarm(
    agents=workers,                    # workers only — the planner is built internally
    planner_model_name="gpt-5.4",
    judge_model_name="gpt-5.4",
    max_planner_depth=1,
    max_loops=1,
)
swarm.run("Build a go-to-market strategy for a B2B SaaS product.")

Others

from swarms import (
    MultiAgentRouter,      # routes each task to the best-fit agent
    RoundRobinSwarm,       # fixed rotation
    LLMCouncil,            # members answer, rank peers anonymously, chairman synthesizes
    BatchedGridWorkflow,   # agent i runs task i
    AutoSwarmBuilder,      # generates the agents and architecture from a description
    SpreadSheetSwarm,      # structured tabular processing
    AdvisorSwarm, SelfMoASeq, HybridHierarchicalClusterSwarm,
)

builder = AutoSwarmBuilder(name="MarketResearch", description="...", max_loops=1)
builder.run("Research the EV market and find growth opportunities.")

Part 6 — Execution helpers

from swarms import (
    run_agents_concurrently,
    run_agents_with_different_tasks,
    run_agents_concurrently_async,
    batch_agent_execution,
    run_single_agent,
    aggregate,
)

run_agents_concurrently(agents=agents, task="Summarize today's news.", max_workers=8)
run_agents_with_different_tasks([(agent_a, "task A"), (agent_b, "task B")])  # list of tuples
batch_agent_execution(agents=agents, tasks=tasks, max_workers=10)
aggregate(workers=agents, task="...", aggregator_model_name="gpt-5.4")

Note run_agents_with_different_tasks takes a list of (agent, task) tuples, not a dict.

Scheduling

from swarms import CronJob

job = CronJob(agent=agent, interval="10minutes", job_id="market-check")
job.run(task="Check for unusual market activity.")

interval is "<number><unit>", and the unit must be one of second, seconds, minute, minutes, hour, hours. Abbreviations like "30s" raise CronJobConfigError, as does a zero interval.

Loading agents from files

from swarms import AgentLoader

loader = AgentLoader(concurrent=True)
agents = loader.load_agents_from_markdown("agents/")   # also: _from_yaml, _from_csv
agent = loader.load_agent_from_markdown("agents/researcher.md")

Part 7 — Pitfalls

Don'tDoWhy
from swarms.structs.agent import Agentfrom swarms import AgentSubmodule paths move between versions
tools=[]tools=NoneEmpty list breaks schema generation
tools=[f] with max_loops=1max_loops=3Loop 1 calls the tool; it needs loop 2 to use the result
Same agent_name on several agentsUnique namesMEMORY.md is keyed on it — they corrupt each other
streaming_on=True + streaming_callbackPick oneThey conflict
CouncilAsAJudge(agents=..., judge=...)Model-name kwargsIt takes no agents or judge argument
DebateWithJudge(agents=[p, c], judge=j)pro_agent=, con_agent=, judge_agent=Those kwarg names don't exist
HeavySwarm(num_agents=4, model_name=...)question_agent_model_name=, worker_model_name=Those kwarg names don't exist
from swarms import PlannerWorkerSwarmfrom swarms.structs.planner_worker_swarm import ...Not exported at the top level
swarm_type="AutoSwarmBuilder"Use the class directlyNot one of the 16 router types
GraphWorkflow.add_node(Node(...))add_node(agent)It takes the agent itself
Building agents inside a loopBuild once, reuseConstruction is expensive
context_compression=False on long runsLeave it TrueThe run will hit the context wall
Bare max_loops="auto" in productionInteger max_loopsAutonomous runs have no natural stopping point

Production configuration

agent = Agent(
    agent_name="ProductionAgent",
    agent_description="...",
    model_name="gpt-5.4",
    max_loops=3,
    context_length=32000,
    context_compression=True,
    persistent_memory=True,
    autosave=True,
    retry_attempts=3,
    fallback_models=["claude-sonnet-4-6"],
    verbose=False,
)

Debugging

  • verbose=True — full internal logging
  • show_tool_execution_output=True — raw tool returns
  • output_type="all" — the complete conversation instead of just the final message
  • agent.get_all_selected_tools() — the autonomous tool roster
  • agent.short_memory.return_history_as_string() — dump the conversation

Reference

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Perform comprehensive code reviews focusing on best practices, security vulnerabilities, performance optimization, and maintainability

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

kyegomez/swarms7.3천2026년 10월 18일 업데이트

Review Python code for bugs, missing tests and security issues using the team's shared standards

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

kyegomez/swarms7.3천2026년 10월 18일 업데이트

Write git commit messages and pull request titles in the WARP format used by the swarms repo

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

kyegomez/swarms7.3천2026년 10월 18일 업데이트

Create effective data visualizations using best practices for clarity, accuracy, and visual communication of insights

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

kyegomez/swarms7.3천2026년 10월 18일 업데이트

Perform comprehensive financial analysis including DCF modeling, ratio analysis, and financial statement evaluation for companies and investment opportunities

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

kyegomez/swarms7.3천2026년 10월 18일 업데이트

kyegomez의 스킬 모두 보기

이 스킬의 문제 신고