🤖strands-agent
- プラグイン
- aws-dev-toolkit
- ソース
- GitHub で見る ↗
説明
Strands Agents SDK と Bedrock AgentCore を使用して、AIエージェントのスキャフォールドおよびビルドを行います。 次のような場合に使用: 新しいエージェントプロジェクトの作成、AgentCoreアプリケーションのグリーンフィールド開発、Strandsを使ったエージェントのプロトタイピング、またはStrandsフレームワークに関する質問への対応。 TypeScriptおよびPythonの両方に対応しています。
原文を表示
Scaffold and build AI agents using the Strands Agents SDK with Bedrock AgentCore. Use when creating new agent projects, building greenfield AgentCore applications, prototyping agents with Strands, or when asked about the Strands framework. Covers both TypeScript and Python.
ユースケース
- ✓新しいエージェントプロジェクトを作成するとき
- ✓AgentCoreアプリケーションをゼロから開発するとき
- ✓Strandsを使ったエージェントをプロトタイピングするとき
- ✓Strandsフレームワークについて質問に対応するとき
本文(日本語訳)
Strands Agents SDK を使用し、Amazon Bedrock AgentCore 上にデプロイされる AI Agent を構築します。
最初に: 使用言語の確認
コードを書く前に、ユーザーに以下を確認してください:
TypeScript か Python か? (新規プロジェクトには TypeScript を推奨 — 強い型付け、優れた開発者体験、Strands の一流サポートがあります。Python も完全サポートされています。)
ユーザーが希望を示さない場合は、TypeScript をデフォルトとします。
進め方
- Agent の目的を一文で明確化する。「かつ(and)」が必要な場合は、複数の Agent への分割を検討する
- 言語の希望を確認する(TS 推奨、Python も対応)
- Agent が必要とするツールを特定する(PoC は 3〜5 個に絞る)
- メモリの要件を決定する: メモリなし / STM のみ / STM + LTM
- references/ 内のパターンを参考にプロジェクトをスキャフォールドする
- オブザーバビリティのセットアップを含める(OTel トレーシングは組み込み済み — エンドポイントを設定するだけ)
- Strands Evals を使った eval スキャフォールドを含める(TS の Agent であっても、eval は Python で記述)
- AgentCore CLI を使ったデプロイ手順を含める
最速 PoC への道: AgentCore CLI
動作するデプロイ済み Agent への最短ルートとして、AgentCore Starter Toolkit CLI を使用してください。 設定・デプロイ・メモリプロビジョニング・起動をすべて処理します。
# ツールキットのインストール
pip install bedrock-agentcore-starter-toolkit
# Agent の設定
agentcore configure --entrypoint agent.py --name my-agent
# AWS へのデプロイ(CodeBuild を使用、Docker 不要)
agentcore deploy
# 起動
agentcore invoke '{"prompt": "Hello!"}'
# ステータス確認
agentcore status
# 完了後のリソース削除
agentcore destroy --force
完全な CLI リファレンスは references/agentcore-cli.md を参照してください。
TypeScript プロジェクトのセットアップ
mkdir my-agent && cd my-agent
npm init -y
npm pkg set type=module
npm install @strands-agents/sdk
npm install --save-dev @types/node typescript
完全な TypeScript Agent パターンは references/typescript-patterns.md を参照してください。
Python プロジェクトのセットアップ
mkdir my-agent && cd my-agent
python -m venv .venv && source .venv/bin/activate
pip install strands-agents bedrock-agentcore
完全な Python Agent パターンは references/python-patterns.md を参照してください。
オブザーバビリティ & トレーシング
Strands には OpenTelemetry が組み込まれています。 Agent の起動・モデル呼び出し・ツール実行のたびに、OTel スパンが自動的に出力されます。送信先を設定するだけで使えます。
- AgentCore デプロイ済み Agent: OTel はデフォルトで有効 → CloudWatch Logs、X-Ray トレース、GenAI ダッシュボードへ送信
- ローカル開発:
OTEL_EXPORTER_OTLP_ENDPOINTを設定して Jaeger、Grafana、Langfuse 等にルーティング - 無効化:
agentcore configure --disable-otel
完全なセットアップ・サードパーティバックエンド・トレース属性の設定については references/agentcore-integrations.md を参照してください。
Strands Evals による評価
最初のリリースから eval を組み込みましょう。 Strands Evals は LLM-as-a-Judge 評価を提供し、9 種類以上の組み込み Evaluator を備えています:
- OutputEvaluator: カスタムルーブリックに基づく品質スコアリング
- TrajectoryEvaluator: Agent が正しいツールを正しい順序で使用したか?
- HelpfulnessEvaluator: 7 段階の有用性スケール
- FaithfulnessEvaluator: レスポンスがコンテキストに基づいているか?(ハルシネーション対策)
- HarmfulnessEvaluator: 安全性チェック
- ToolSelectionAccuracyEvaluator / ToolParameterAccuracyEvaluator: ツールレベルの正確性
- GoalSuccessRateEvaluator: セッション全体を通じてユーザーが目標を達成できたか?
- ActorSimulator: 会話テスト用にリアルなマルチターンユーザーをシミュレート
pip install strands-agents-evals
Eval は Python のみ対応です。TypeScript の Agent であっても、eval スイートは Python で記述してください。
eval のコードパターン・トレースベースの評価・マルチターンシミュレーション・テストケースの自動生成については references/agentcore-integrations.md を参照してください。
メモリ選択ガイド
| シナリオ | メモリモード | 備考 |
|---|---|---|
| ステートレスなツール呼び出し Agent | NO_MEMORY | 最もシンプルかつ低コスト |
| セッション内でのマルチターン会話 | STM_ONLY | 30 日間保持、会話履歴を保存 |
| セッションをまたいだパーソナライズ | STM_AND_LTM | セッション間で好み・事実・要約を抽出 |
メモリはオプトイン方式です。まずなしで始め、必要になったら追加してください。
注意事項
- AgentCore CLI のデプロイは Python 専用 — Agent が TypeScript であっても、
agentcoreCLI 自体は Python ツールです。TS Agent はコンテナ内で動作します。 - TypeScript Agent はコンテナ化デプロイが必要 — AgentCore CLI で TS Agent を設定する際は
--deployment-type containerを指定してください。 - デフォルトモデルは Claude Sonnet — Strands は Bedrock 経由で
global.anthropic.claude-sonnet-4-5-20250929-v1:0をデフォルトとして使用します。AWS アカウントでモデルアクセスを有効化する必要があります。 - AWS 認証情報が必要 — Strands はデフォルトで Bedrock を使用します。
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYが設定されているか、IAM ロールを使用していることを確認してください。 - ツール数は重要 — ツールが多いほど推論ステップが増え、速度低下とコスト増加につながります。PoC は 3〜5 個のツールに抑えてください。
- Zod は同梱済み —
@strands-agents/sdkには TypeScript のツール入力バリデーション用に Zod がバンドルされています。別途インストールは不要です。 - メモリのプロビジョニングには時間がかかります — STM: 約 30〜90 秒、LTM: 約 120〜180 秒。CLI は ACTIVE ステータスになるまで待機します。
agentcore destroyはすべてを削除します — メモリリソースも含めて削除されます。先に--dry-runで確認してください。- セッションのライフサイクル — アイドルタイムアウトのデフォルトは 900 秒(15 分)です。長いセッションが必要な場合は、configure 時に
--idle-timeoutと--max-lifetimeを設定してください。 - VPC 設定は変更不可 — VPC 設定でデプロイした後は変更できません。新しい Agent 設定を作成してください。
- AgentCore では OTel がデフォルトで有効 — トレースは CloudWatch / X-Ray に送信されます。不要な場合は
--disable-otelで無効化してください。 - Strands Evals は Python 専用 — TypeScript の Agent であっても、eval は Python で記述してください。eval フレームワークは Agent と同じ Bedrock モデルを使用します。
- Eval はコストがかかります — LLM-as-a-Judge 評価はモデルを呼び出すたびにコストが発生します。コンソール出力を抑制するには、eval タスク関数内で
callback_handler=Noneを使用してください。 - メモリのバッチ処理には
close()が必要 —batch_size > 1を使用する場合は、必ずwithブロックを使用するかclose()を呼び出してください。そうしないとバッファ内のメッセージが失われます。
出力内容
新しい Agent プロジェクトをスキャフォールドする際は、以下を生成してください:
- すべてのファイルを含む完全なプロジェクト構造
- 少なくとも 1 つのカスタムツールを持つ Agent エントリーポイント
- オブザーバビリティのセットアップ(OTel エンドポイント設定、環境変数)
- eval スキャフォールド(Strands Evals を使った少なくとも 1 つのテストケースを含む
evals/ディレクトリ — TS Agent であっても Python で記述) - セットアップ・デプロイ・オブザーバビリティ・eval の手順を含む README
- 言語に適した
.gitignore - デプロイコマンド(ローカル開発 + AgentCore クラウド)
原文(English)を表示
You are building an AI agent using the Strands Agents SDK deployed on Amazon Bedrock AgentCore.
First: Clarify Language
Before writing any code, ask the user:
TypeScript or Python? (TypeScript is recommended for new projects — it has strong typing, good DX, and first-class Strands support. Python is fully supported too.)
Default to TypeScript if the user doesn't have a preference.
Process
- Clarify the agent's purpose — one sentence. If it needs "and", consider multiple agents.
- Clarify language preference (TS preferred, Python supported)
- Identify the tools the agent needs (keep to 3-5 for a PoC)
- Decide on memory needs: no memory, STM only, or STM+LTM
- Scaffold the project using the patterns in references/
- Include observability setup (OTel tracing is built in — just configure the endpoint)
- Include an eval scaffold using Strands Evals (even for TS agents, evals are Python)
- Include deployment instructions using the AgentCore CLI
Quick PoC Path: AgentCore CLI
For the fastest path to a working deployed agent, use the AgentCore Starter Toolkit CLI. It handles configuration, deployment, memory provisioning, and invocation.
# Install the toolkit
pip install bedrock-agentcore-starter-toolkit
# Configure your agent
agentcore configure --entrypoint agent.py --name my-agent
# Deploy to AWS (uses CodeBuild, no Docker needed)
agentcore deploy
# Invoke it
agentcore invoke '{"prompt": "Hello!"}'
# Check status
agentcore status
# Tear down when done
agentcore destroy --force
See references/agentcore-cli.md for the full CLI reference.
TypeScript Project Setup
mkdir my-agent && cd my-agent
npm init -y
npm pkg set type=module
npm install @strands-agents/sdk
npm install --save-dev @types/node typescript
See references/typescript-patterns.md for complete TypeScript agent patterns.
Python Project Setup
mkdir my-agent && cd my-agent
python -m venv .venv && source .venv/bin/activate
pip install strands-agents bedrock-agentcore
See references/python-patterns.md for complete Python agent patterns.
Observability & Tracing
Strands has OpenTelemetry built in. Every agent invocation, model call, and tool execution emits OTel spans automatically. You just configure where to send them.
- AgentCore deployed agents: OTel is enabled by default → CloudWatch Logs, X-Ray traces, GenAI dashboard
- Local development: Set
OTEL_EXPORTER_OTLP_ENDPOINTto route to Jaeger, Grafana, Langfuse, etc. - Disable:
agentcore configure --disable-otel
See references/agentcore-integrations.md for full setup, third-party backends, and trace attribute configuration.
Evaluation with Strands Evals
Ship evals from day one. Strands Evals provides LLM-as-a-Judge evaluation with 9+ built-in evaluators:
- OutputEvaluator: Custom rubric-based quality scoring
- TrajectoryEvaluator: Did the agent use the right tools in the right order?
- HelpfulnessEvaluator: 7-point helpfulness scale
- FaithfulnessEvaluator: Is the response grounded in context? (anti-hallucination)
- HarmfulnessEvaluator: Safety check
- ToolSelectionAccuracyEvaluator / ToolParameterAccuracyEvaluator: Tool-level correctness
- GoalSuccessRateEvaluator: Did the user achieve their goal across a full session?
- ActorSimulator: Simulates realistic multi-turn users for conversation testing
pip install strands-agents-evals
Evals are Python-only. Even for TypeScript agents, write your eval suite in Python.
See references/agentcore-integrations.md for eval code patterns, trace-based evaluation, multi-turn simulation, and auto-generated test cases.
Memory Decision Guide
| Scenario | Memory Mode | Notes |
|---|---|---|
| Stateless tool-calling agent | NO_MEMORY | Simplest, cheapest |
| Multi-turn conversation within a session | STM_ONLY | 30-day retention, stores conversation history |
| Personalization across sessions | STM_AND_LTM | Extracts preferences, facts, summaries across sessions |
Memory is opt-in. Start without it, add when you need it.
Gotchas
- AgentCore CLI is Python-only for deployment — even if your agent is TypeScript, the
agentcoreCLI itself is a Python tool. Your TS agent runs in a container. - TypeScript agents need containerized deployment — use
--deployment-type containerwhen configuring TS agents with the AgentCore CLI - Default model is Claude Sonnet — Strands defaults to
global.anthropic.claude-sonnet-4-5-20250929-v1:0via Bedrock. You need model access enabled in your AWS account. - AWS credentials required — Strands uses Bedrock by default. Ensure
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYare set, or use IAM roles. - Tool count matters — more tools = more reasoning steps = slower + more expensive. Keep PoCs to 3-5 tools.
- Zod is included —
@strands-agents/sdkbundles Zod for TypeScript tool input validation. No separate install needed. - Memory provisioning takes time — STM: ~30-90s, LTM: ~120-180s. The CLI waits for ACTIVE status.
agentcore destroydeletes everything — including memory resources. Use--dry-runfirst.- Session lifecycle — idle timeout defaults to 900s (15min). Set
--idle-timeoutand--max-lifetimeduring configure if you need longer sessions. - VPC config is immutable — once deployed with VPC settings, you can't change them. Create a new agent config instead.
- OTel is on by default in AgentCore — traces go to CloudWatch/X-Ray. Disable with
--disable-otelif you don't want it. - Strands Evals is Python-only — even for TypeScript agents, write evals in Python. The eval framework uses the same Bedrock models as your agent.
- Evals cost money — each LLM-as-a-Judge evaluation invokes a model. Use
callback_handler=Nonein eval task functions to suppress console output. - Memory batching requires close() — if using
batch_size > 1, you MUST use awithblock or callclose()or buffered messages are lost.
Output
When scaffolding a new agent project, generate:
- Complete project structure with all files
- Agent entrypoint with at least one custom tool
- Observability setup (OTel endpoint config, env vars)
- Eval scaffold (
evals/directory with at least one test case using Strands Evals — Python, even for TS agents) - README with setup, deployment, observability, and eval instructions
.gitignoreappropriate for the language- Deployment commands (local dev + AgentCore cloud)
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。