harness-sdk
フレームワークstrands-agents/harness-sdk
オープンソースの Python および TypeScript 向け AI エージェント開発 SDK。
概要
Strands Agents は、Python と TypeScript で AI エージェントを構築・実行するためのモデル駆動型オープンソース SDK です。ライフサイクル制御、ツール呼び出し、構造化出力、MCP、マルチエージェントパターン、メモリ、セッション、ストリーミング出力、ガードレール、トレーシング、評価を内蔵し、Bedrock、Anthropic、OpenAI、Gemini などの複数のモデルプロバイダーをサポートしています。
README プレビュー
\n \n \n \n \n \n \n \n \n\n \n Strands Agents\n \n\n \n A model-driven approach to building AI agents in just a few lines of code.\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n Documentation\n ◆ Samples\n ◆ MCP Server\n ◆ Discord\n \n\n\nStrands Agents is an open-source SDK for building and running AI agents in Python and TypeScript. Choose Strands when you would otherwise write your own agent loop: it runs in your process with no hosted control plane, and it covers the jobs a hand-rolled loop grows into. In one SDK you get [lifecycle controls](https://strandsagents.com/docs/user-guide/concepts/agents/agent-loop/) (turn limits, token budgets, cancellation, stop reasons), [tools](https://strandsagents.com/docs/user-guide/concepts/tools/) and [structured output](https://strandsagents.com/docs/user-guide/concepts/agents/structured-output/), [MCP](https://strandsagents.com/docs/user-guide/concepts/tools/mcp-tools/), [multi-agent patterns](https://strandsagents.com/docs/user-guide/concepts/multi-agent/multi-agent-patterns/), [memory](https://strandsagents.com/docs/user-guide/concepts/memory/overview/) and [sessions](https://strandsagents.com/docs/user-guide/concepts/agents/session-management/), [model portability](https://strandsagents.com/docs/user-guide/concepts/model-providers/), [streaming](https://strandsagents.com/docs/user-guide/concepts/streaming/), [guardrails](https://strandsagents.com/docs/user-guide/safety-security/guardrails/), [tracing](https://strandsagents.com/docs/user-guide/observability-evaluation/observability/), and [evals](https://strandsagents.com/docs/user-guide/evals-sdk/quickstart/).\n\nThis monorepo contains Strands harness, the Python and TypeScript SDKs, the documentation site, and supporting packages:\n\n| Directory | Description |\n|-----------|-------------|\n| [`harness-py/`](harness-py/) | Python Strands harness: fully assembled agent via `create_harne
FAQ (5)
トラブル対応Strands Agent を別のエージェント内でツールとして使用する際に、出力がインターリーブしたり重複したりする問題はどうすれば修正できますか?
サブエージェントに callback_handler=None を設定して、そのトークンストリームがオーケストレーターの出力チャネルを通じて出力されないようにします。サブエージェントは引き続き実行されて結果を返しますが、最終レスポンスをストリーミングするのは親/オーケストレーターのみになります。
sub_agent = Agent(
model=model,
system_prompt="You are a news fetcher.",
tools=[some_tool],
callback_handler=None # Required when this agent is used as a tool
)
@tool(name="live_news", description="Fetches latest news")
def live_news(input: str) -> str:
result = sub_agent(input)
return str(result) # Clean text returned to the orchestrator
orchestrator = Agent(
model=model,
system_prompt="You are Jarvis.",
tools=[live_news]
)
オーケストレーターの最終出力も抑制したい場合を除き、オーケストレーターのコールバックハンドラーを無効にしないでください。TypeScript のカスタムエージェントラッパーでは、これに相当する設定はネストされたエージェントの printer: false です。
トラブル対応Strands MCPClientで発生する'Unsupported protocol version from the server: 2026-07-28'エラーの解決方法
strands-agents をバージョン 1.55.0 以降にアップグレードしてください: pip install -U strands-agents。旧リリースでは mcp>=1.23.0,<2.0.0 にピン留めされ、レガシーな ClientSession.initialize() ハンドシェイクを使用していたため、最新の 2026-07-28 プロトコルをネゴシエートするサーバー(例: supportedVersions=["2026-07-28"] を持つ AWS Bedrock AgentCore Gateway)を拒否してしまいます。v1.55.0 では依存関係の範囲が mcp 2.x を許可するようになり、MCPClient は negotiate_session を介して接続します。これにより、mcp 2.x 上では新しいプロトコルをネゴシエートし、古いサーバーに対しては透過的にレガシーハンドシェイクへフォールバックします。
トラブル対応Strands OpenAIModelがチャットモードでOpenRouterを使用した際にトークン使用量がゼロと報告されるのはなぜですか?
OpenRouter は、choices[0].finish_reason を含む最終ストリームチャンクで usage オブジェクトを送信します。Strands TypeScript SDK 1.19.0 では、_streamChat は choices 配列が空のチャンクからのみ usage を読み取るため、その最終チャンクはスキップされ、agent.metrics.accumulatedUsage は { inputTokens: 0, outputTokens: 0, totalTokens: 0 } のままになります。
暫定的な回避策: 代わりに Responses API を使用してください:
new OpenAIModel({
api: 'responses',
modelId: 'openai/gpt-6-luna',
apiKey: process.env.OPENROUTER_API_KEY,
clientConfig: { baseURL: 'https://openrouter.ai/api/v1' },
})
コード修正: _streamChat で、choices が空かどうかを確認する前に、すべてのチャンクで chunk.usage を読み取ります:
if (chunk.usage) {
bufferedUsage = chunk.usage
}
if (!chunk.choices || chunk.choices.length === 0) {
continue
}
利用可能な場合は、修正 fix(openai): read chat usage reported on the finish_reason chunk を含む Strands リリースにアップグレードしてください。
トラブル対応StrandsがClaude Haiku 5.5で1Mではなく200kのコンテキストウィンドウを使用するのはなぜですか?
Strands 1.58.1 には Claude Haiku 5.5 用のコンテキストウィンドウのマッピングがないため、BedrockModel.context_window_limit はデフォルトの 200,000 トークンにフォールバックします。このため、estimate_utilization(150000) は 0.15 ではなく 0.75 を返し、しきい値 0.7 の場合に 700k ではなく約 140k トークンでプロアクティブな要約がトリガーされる可能性があります。
即時の回避策: 上限を明示的に設定してください。
from strands.models import BedrockModel
model = BedrockModel(
model_id="eu.anthropic.claude-haiku-5-5",
region_name="eu-west-2",
context_window_limit=1_000_000,
)
global.anthropic.claude-haiku-5-5 にも同じ値を使用してください。恒久的な修正は、PR #4998 を含む Strands リリースにアップグレードすることです。この PR では、anthropic.claude-haiku-5-5 と claude-haiku-5-5 の 1,000,000 トークンのエントリが Python と TypeScript の両方のデフォルトに追加されます。
トラブル対応AWS_REGION が設定されていない場合、Strands CLI の Bedrock モデル一覧が空になるのはなぜですか?
これは @strands-agents/cli 0.1.0 で発生します。原因は、STS の認証情報検証が us-east-1 にフォールバックする一方で、Bedrock のモデル検出ではリージョンが解決されなかった場合にリージョンが省略され、その結果カタログリクエストがサイレントに失敗し、モデルが 0 件返されることです。
暫定的な回避策:CLI を起動する前にリージョンを設定してください:
export AWS_REGION=us-east-1
strands
または、config.json の providers.environment.AWS_REGION を、お使いの Bedrock モデルが利用可能なリージョンに設定してください。
修正は PR #4581(コミット 9b7657f1)により main で利用可能です。awsClientConfiguration は、一貫した優先順位でリージョンを解決するようになりました:明示的なリージョン → プロファイルから導出されたリージョン → us-east-1。この修正を含む CLI リリースに更新してください。config.json が書き換えられて providers.environment.AWS_REGION が消えてしまう場合、それは別の未解決の問題であるため、個別に報告してください。