agent-squad-python
Skill này làm gì
Skill này là hướng dẫn xây dựng ứng dụng Python với agent-squad, một framework cho hệ thống nhiều agent AI. Skill giải thích loại agent nào phù hợp với từng nhu cầu. Dành cho lập trình viên Python xây dựng trợ lý hoặc nhóm agent AI.
Khi nào nên dùng
- ✓Khi bạn đang xây dựng ứng dụng Python định tuyến yêu cầu đến nhiều agent AI chuyên biệt.
- ✓Khi bạn cần một trợ lý đơn lẻ, một chuỗi xử lý cố định, một nhóm có supervisor, hoặc câu trả lời dựa trên dữ liệu.
- ✓Khi bạn muốn kết nối các máy chủ công cụ bên ngoài với agent qua giao thức MCP.
Liên kết skill
https://github.com/2FastLabs/agent-squad/blob/main/python/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy giúp tôi xây dựng ứng dụng Python dùng agent-squad để định tuyến câu hỏi của khách hàng đến một agent thanh toán và một agent hỗ trợ.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích khi nào nên dùng một trợ lý đơn lẻ, nhiều agent có orchestrator, agent dựa trên dữ liệu để trả lời khớp với số liệu, chuỗi xử lý cho các bước cố định, hoặc supervisor cho nhóm. Skill chỉ bạn đến mã nguồn và tài liệu để xem chi tiết chính xác.
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.
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
Agentsubclass; no orchestrator needed, callprocess_requestdirectly. - Several specialists — multiple agents + an
AgentSquadorchestrator; 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 leadBedrockLLMAgentorAnthropicAgentdelegates to a team of sub-agents via an internal tool loop, maintaining shared context. Can itself be registered in anAgentSquad. - External tool servers —
MCPToolProvider(requiresagent-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
Câu hỏi thường gặp
Skill có cung cấp đầy đủ tài liệu API không?
Không. Đây là hướng dẫn và bản đồ định hướng. Skill chỉ bạn đến mã nguồn và tài liệu để xem chữ ký hàm chính xác.
Cần phiên bản Python nào?
Python 3.11 trở lên.
Có kết nối được công cụ bên ngoài không?
Có. Một nhà cung cấp công cụ MCP tùy chọn có thể kết nối nhiều máy chủ MCP để các công cụ của chúng sẵn có cho agent.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12830
- Giấy phép
- Apache-2.0
- Cập nhật
- 8/10/2026
Bình luận
- …
Thêm skill từ kho mã này
agent-squad-swift
7.8kGiúp agent của bạn xây dựng ứng dụng Swift cho iPhone và Mac, chạy cùng lúc nhiều trợ lý AI với định tuyến, công cụ và lưu trữ trên thiết bị.
agent-squad-typescript
7.8kGiúp agent của bạn xây dựng ứng dụng Node.js nơi nhiều agent AI cùng làm việc, có định tuyến, lưu trữ dữ liệu và kết nối tới công cụ bên ngoài.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.