跳到正文
Skillpedia
智能体7.8k · #12830

agent-squad-python

它能做什么

这项技能是一份指南,教你用 agent-squad 构建 Python 应用。agent-squad 是一个多智能体 AI 系统框架。它会说明每种需求应选用哪类智能体。它适合构建 AI 助手或 AI 智能体团队的 Python 开发者。

适用场景

  • ✓当你要构建一个 Python 应用,把请求分发给多个专业 AI 智能体的时候。
  • ✓当你需要单个助手、固定流水线、主管团队,或基于数据的回答的时候。
  • ✓当你想通过 MCP 协议把外部工具服务器接入智能体的时候。

技能链接

https://github.com/2FastLabs/agent-squad/blob/main/python/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“请用 agent-squad 构建一个 Python 应用,把客户问题分别分发给账单智能体和客服智能体。”

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

工作原理

它会说明何时使用单个助手、带协调器的多个智能体、必须与数据一致的基于数据的智能体、用于固定步骤的链式流程,以及用于团队的主管模式。具体细节请参考源代码和文档。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

agent-squad Python — assistant guide

Async-first, dependency-optional multi-agent orchestration framework (Python 3.11+). This is a guide and a map — not an API reference. Read exact signatures from the source (python/src/agent_squad/) and the docs site (docs/src/content/docs/); this file tells you what to use, when, and what to watch out for.

When to use what

  • One assistant — a single Agent subclass; no orchestrator needed, call process_request directly.
  • Several specialists — multiple agents + an AgentSquad orchestrator; the classifier routes each turn to the right agent automatically.
  • Answers must not drift from data (prices, balances, live stock) — GroundedAgent: a gatherer LLM calls tools and sees raw results but never speaks to the user; an isolated presenter LLM writes the reply grounded only on curated facts.
  • Fixed pipeline — ChainAgent: routes the output of one agent as the input to the next, sequentially.
  • Team coordination — SupervisorAgent: a lead BedrockLLMAgent or AnthropicAgent delegates to a team of sub-agents via an internal tool loop, maintaining shared context. Can itself be registered in an AgentSquad.
  • External tool servers — MCPToolProvider (requires agent-squad[mcp]) connects any number of MCP servers (stdio or SSE) and makes their tools available to any agent.

How to install

All third-party integrations are optional extras — never forced on users who don't need them.

pip install agent-squad                  # core only (no LLM runtime)
pip install "agent-squad[aws]"           # + boto3 — BedrockLLMAgent, BedrockClassifier, DynamoDbChatStorage, etc.
pip install "agent-squad[anthropic]"     # + anthropic SDK — AnthropicAgent, AnthropicClassifier
pip install "agent-squad[openai]"        # + openai SDK — OpenAIAgent, OpenAIClassifier
pip install "agent-squad[sql]"           # + libsql-client — SqlChatStorage (Turso/libSQL)
pip install "agent-squad[strands-agents]"# + strands-agents — StrandsAgent
pip install "agent-squad[dakera]"        # + dakera — DakeraRetriever
pip install "agent-squad[mcp]"           # + mcp — MCPToolProvider
pip install "agent-squad[all]"           # everything except strands-agents

How a turn works

AgentSquad.route_request is the one entry point worth memorising. It is a coroutine — you must await it.

import asyncio
from agent_squad.orchestrator import AgentSquad
from agent_squad.agents import BedrockLLMAgent, BedrockLLMAgentOptions
from agent_squad.classifiers import BedrockClassifier, BedrockClassifierOptions

orchestrator = AgentSquad(
    classifier=BedrockClassifier(BedrockClassifierOptions())
)
orchestrator.add_agent(BedrockLLMAgent(BedrockLLMAgentOptions(
    name="General Assistant",
    description="Handles general knowledge questions",
)))

async def main():
    response = await orchestrator.route_request(
        user_input="What is the capital of France?",
        user_id="user-123",
        session_id="session-abc",
    )

    if response.streaming:
        # response.output is an async generator of AgentStreamResponse
        async for chunk in response.output:
            if chunk.text:
                print(chunk.text, end="", flush=True)
            if chunk.final_message:
                pass  # full ConversationMessage — already persisted
    else:
        # response.output is a ConversationMessage
        print(response.output.content[0]["text"])

asyncio.run(main())

AgentResponse has three fields: metadata (AgentProcessingResult), output, and streaming (bool). Always branch on response.streaming — the type of output differs.

To stream back from route_request, pass stream_response=True:

response = await orchestrator.route_request(
    user_input="...",
    user_id="u1",
    session_id="s1",
    stream_response=True,
)

If no agent is selected and no default agent is configured, route_request returns an AgentResponse with the NO_SELECTED_AGENT_MESSAGE text rather than raising.

The pieces

AgentSquad (orchestrator)

from agent_squad.orchestrator import AgentSquad

The top-level object. Holds an agent registry, a classifier, and a ChatStorage.

from agent_squad.types import AgentSquadConfig

orchestrator = AgentSquad(
    options=AgentSquadConfig(
        LOG_CLASSIFIER_OUTPUT=True,
        MAX_MESSAGE_PAIRS_PER_AGENT=20,
        USE_DEFAULT_AGENT_IF_NONE_IDENTIFIED=T
常见问题

它会提供完整的 API 参考吗?

不会。它是一份指南和地图。技能会引导你查看源代码和文档,以获取准确的函数签名。

需要哪个 Python 版本?

Python 3.11 或更高版本。

它能接入外部工具吗?

可以。可选的 MCP 工具提供者可以连接任意数量的 MCP 服务器,使其工具可供智能体使用。

详情

作者的原始描述

Use when building or modifying a Python app that uses the agent-squad Python package — async multi-agent orchestration for Python 3.11+: orchestrator, agents (BedrockLLMAgent, AnthropicAgent, OpenAIAgent, SupervisorAgent, GroundedAgent, ChainAgent, and more), classifier routing (Bedrock, Anthropic, OpenAI), storage (in-memory, DynamoDB, SQL/Turso), retrievers (Amazon KB, Dakera), tools (AgentTools, MCPToolProvider), and custom implementations.

repo: 2FastLabs/agent-squad

热度

GitHub 星标
7.8k
排名
#12830
许可证
Apache-2.0
更新时间
2026/10/8

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能