生产级AI Agent开发SDK,覆盖生命周期控制、工具调用、MCP协议、多Agent协作等,模型和云厂商无关。
一种模型驱动的 AI Agent 开发框架,仅需少量代码即可构建。
文档 ◆ 示例 ◆ MCP Server ◆ Discord
Strands Agents 是一个开源 SDK,用于在 Python 和 TypeScript 中构建和运行 AI Agent。选择 Strands,意味着你不需要自己手写 Agent 循环:它运行在你的进程内,不依赖任何托管控制面,涵盖了手写循环逐渐演进而来的所有功能。一个 SDK 同时提供生命周期控制(轮次限制、Token 预算、取消操作、停止原因)、工具和结构化输出、MCP、多 Agent 模式、记忆与会话、模型可移植性、流式输出、安全护栏、链路追踪和评估能力。
本仓库(monorepo)包含 Strands harness、Python 和 TypeScript SDK、文档站点以及相关支持包:
按你的方式构建。任意模型,任意云。在你写下一行配置之前,上下文管理、执行限制和可观测性就已内置。扩容时切换后端,代码保持不变。
模型无关。 一级支持 Amazon Bedrock、Anthropic、OpenAI 和 Gemini,以及更多提供商和自定义提供商。
保持掌控。 Agent 循环默认对每个决策进行链路追踪。Hook 允许你拦截任意步骤,记录、校验或重定向它。
输出真正可用的结果。 安全护栏在运行前捕获错误。Steering 处理器让 Agent 能够自我修正,而非静默失败。
MCP、流式输出、多 Agent 模式以及结构化输出均已内置。
最简单的方式是使用 Strands harness,一个完全组装好的、最先进的 Agent。只需一次 create_harness()(Python)或 createHarness()(TypeScript)调用,即可获得针对模型、工具、记忆、会话和上下文管理经过基准测试的优化 Agent——从想法到生产环境直接可用。请参考 harness 快速入门,或查看 Python Strands harness 和 TypeScript Strands harness 包开始使用。
pip install strands-harness
from strands_harness import create_harness
agent = create_harness()
agent("Find the slowest test in this repo and explain why it's slow")
npm install @strands-agents/harness
import { createHarness } from '@strands-agents/harness'
const agent = await createHarness()
await agent.invoke("Find the slowest test in this repo and explain why it's slow")
从这里开始获得一个配置完善的 Agent,然后在需要自主掌控 Agent 循环、自己连接工具、模型提供商和记忆时,再深入下探到下方的 SDK。harness 配置参考文档记录了每一个可覆盖的默认值。
快速入门指南涵盖了提供商配置(Amazon Bedrock、Anthropic、OpenAI、Gemini、Ollama 等)。
Strands Harness SDK 让你可以更深入地控制 Agent 的每个部分:循环、工具、模型提供商、记忆、会话和 Hook。你可以在熟悉 Strands harness 之后再深入 SDK,也可以在组装好的默认值不够用时,从头开始构建自己的 harness。
Python SDK(需要 Python 3.10+):
pip install strands-agents strands-agents-tools
from strands import Agent
from strands_tools import calculator
agent = Agent(tools=[calculator])
agent("What is the square root of 1764")
Python SDK README 涵盖了工具、模型提供商、MCP 和双向流式输出。
TypeScript SDK(需要 Node.js 22+):
npm install @strands-agents/sdk
import { Agent } from '@strands-agents/sdk'
const agent = new Agent()
const result = await agent.invoke('What is the square root of 1764?')
console.log(result)
更多内容参见 TypeScript SDK README,包括 Zod 类型化工具、结构化输出和多 Agent 模式。
更多详细指导与示例,请查阅文档:
Strands Harness 指南(快速入门 · 配置参考)
API 参考:Python · TypeScript
生产与部署指南
文档本身位于本仓库的 site/ 目录下,欢迎随代码变更一起提交文档 PR。
Git 操作(提交、分支、PR)在仓库根目录执行。每个包有自己的工具链:
Python SDK(strands-py/):
cd strands-py
pip install hatch
hatch test # 运行单元测试
hatch fmt # 格式化与 lint
TypeScript SDK(strands-ts/):
npm ci # 从仓库根目录安装
npm run build # 构建
npm test # 运行单元测试
文档站点(site/):
cd site
npm install
npm run dev # 本地开发服务器 http://localhost:4321/
我们欢迎贡献!参见贡献指南了解:
报告 Bug 和功能需求
通过 Pull Request 贡献
报告安全问题
在 Discord 上与 Strands 团队和其他用户见面
本项目采用 Apache License 2.0 许可证——详情见 LICENSE.APACHE 文件。
更多信息请参见 CONTRIBUTING。