开源项目

harness-sdk

面向生产环境的 AI agent 开发框架,提供 Python/TypeScript 双语言 SDK,以及一次 createharness() 调用即可获得默认工具、记忆、会话与上下文管理的成品 agent。亮点是模型无关(Bedrock、Anthropic、OpenAI、Gemini 等可切换)、无需托管控制面、agent loop 全程可追踪,内置 MCP、multi-agent 模式、guardrails、streaming 与 eval,适合不想自己维护 agent loop 的团队。Apache 2.0 开源。

README

Strands

Strands Agents

以模型驱动的方式,仅用几行代码构建 AI agent。

GitHub commit activity GitHub open issues GitHub open pull requests License Python harness version TypeScript harness version CLI version Python SDK version TypeScript SDK version

文档 ◆ 示例 ◆ MCP Server ◆ Discord

Strands Agents 是一个开源 SDK,用于在 Python 和 TypeScript 中构建和运行 AI agent。当你本来打算自己编写 agent loop(agent 循环)时,可以选择 Strands:它运行在你的进程内,无需托管的控制平面,并且覆盖了手写循环最终会演化出的那些需求。在同一个 SDK 中,你可以获得 生命周期控制(轮次上限、token 预算、取消、停止原因)、工具与结构化输出、MCP、多 agent 模式、memory 与 sessions、模型可移植性、流式输出、guardrails、tracing 以及 evals。

这个 monorepo 包含 Strands harness、Python 与 TypeScript SDK、文档站点以及配套包:

目录 说明
harness-py/ Python Strands harness:通过 create_harness() 获得组装完整的 agent(PyPI · 文档)
harness-ts/ TypeScript Strands harness:通过 createHarness() 获得组装完整的 agent(npm · 文档)
strands-cli/ strands CLI:在终端中快速原型开发并与 harness agent 对话(npm)
strands-py/ Python SDK:agent loop、模型提供商、工具(PyPI · 发布记录)
strands-ts/ TypeScript SDK:agent loop、模型提供商、工具(npm · 发布记录)
site/ strandsagents.com 文档站点的源码(Astro/Starlight)
team/ 治理与跨 SDK 流程文档(原则、决策、PR 与兼容性指南,以及 designs/ 提案)

为什么选择 Strands

构建一个 agent harness。端到端地掌控它。

  • 按你的方式构建。 任意模型,任意云。在你写第一行配置之前,上下文管理、执行限制与可观测性就已内置。扩展时更换后端,你的代码保持不变。
  • 模型无关。 对 Amazon Bedrock、Anthropic、OpenAI 和 Gemini 提供一等支持,并兼容众多其他提供商以及自定义提供商。
  • 始终掌控。 agent loop 默认追踪每一个决策。Hooks 让你可以拦截任意步骤,对其记录、校验或重定向。
  • 交付真正可用的结果。 Guardrails 在错误执行前将其拦截。Steering handlers 让 agent 自我纠正,而不是静默失败。

MCP、流式输出、多 agent 模式与结构化输出均已内置。

快速开始

最简单的入门方式是使用 Strands harness,一个组装完整、业界领先的 agent。一次 create_harness()(Python)或 createHarness()(TypeScript)调用,即可获得一个经过优化的 agent,其在模型、工具、memory、sessions 与上下文管理方面均采用经过基准测试的默认配置——随时可以从想法走向生产。请参考 harness 快速开始,或查看 Python Strands harness 与 TypeScript Strands harness 包以开始使用。

Python

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")

TypeScript

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 loop 并自行接入工具、模型提供商与 memory 时,再下探到下面的 SDK。harness 配置参考记录了每一个你可以覆盖的默认值。

快速开始指南涵盖了配置提供商的内容(Amazon Bedrock、Anthropic、OpenAI、Gemini、Ollama 等)。

使用 SDK

Strands Harness SDK 让你可以更深入,掌控 agent 的每一个部分:loop、工具、模型提供商、memory、sessions 与 hooks。你可以在使用 Strands harness 之后深入 SDK,或者当你觉得组装好的默认配置不足以满足需求、希望从零构建自己的 harness 时使用它。

Python

需要 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

需要 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 模式。

文档

有关详细指引与示例,请查阅我们的文档:

文档本身位于本 monorepo 的 site/ 下,欢迎在提交代码变更的同时提交文档 PR。

开发

Git 操作(提交、分支、PR)在仓库根目录进行。每个包有自己的工具链:

Python SDK(strands-py/):

cd strands-py
pip install hatch
hatch test        # run unit tests
hatch fmt         # format & lint

TypeScript SDK(strands-ts/):

npm ci            # install from repo root
npm run build     # build
npm test          # run unit tests

文档站点(site/):

cd site
npm install
npm run dev       # local dev server at http://localhost:4321/

参与贡献 ❤️

我们欢迎贡献!详见我们的贡献指南,其中涵盖:

  • 报告 bug 与功能请求
  • 开发环境搭建
  • 通过 Pull Request 贡献
  • 行为准则
  • 报告安全问题

与团队保持联系

来 Discord 与 Strands 团队及其他用户交流

许可证

本项目采用 Apache License 2.0 许可——详见 LICENSE.APACHE 文件。

安全

更多信息请参阅 CONTRIBUTING。

开源项目strands-agents2026-09-23原文

相关内容