はじめに
今話題のAmazon Bedrock AgentCore、東京リージョンにも登場し、一般提供も開始されたことで気づけば一大トレンドですね。
機能が多くて追っかけるのが大変ですが、なんとか私も最近入門しました。
本記事では一番メジャーなRuntime機能について解説していければと思います。また、今後も各機能解説していくような記事を書く予定です
Amazon Bedrock AgentCore Runtimeとは
概要
「Runtime」は、作成したエージェントを実際に動作させるための実行環境を指します。
つまり、ローカルで開発したエージェントやStrandsなどで構築したエージェントを、Bedrock上のマネージド環境にデプロイして実行できるようにする仕組みです。
Runtimeを利用することで、以下のような利点があります。
- サーバー管理が不要:エージェントをコンテナ化してECRに登録し、Bedrockが自動的に実行環境を用意してくれる
- 統一されたAPI経由で呼び出せる:InvokeAgentRuntime APIを使って、Lambdaや他のアプリケーションから一貫した形で利用可能
- スケーリングやログ管理もマネージド:トラフィック増加時にもスケールが自動で行われ、CloudWatch経由で観測ができる
イメージ
文字だけだとイメージが掴みにくいと思うのですが、公式の図だと以下のようになっています。
DockerイメージをビルドしてECRにプッシュし、AgentCore CLIやAWS SDKを使ってRuntimeとして登録・起動するだけで動作させることができます。
イメージとしてはBedrock上で動く自作エージェントのホスティング環境というのが近いです。
実装手順
必要なパッケージをインストールしておく
BedrockAgentCoreには、Starter Toolkitという便利アイテムがあり、これを使うと簡単にデプロイまでやってくれます。
まずは利用するために、下記のコマンドでbedrock-agentcore-starter-toolkitをインストールします。
pip install bedrock-agentcore
自作エージェントをAgentCore 仕様に変更する
今回はAgentCorenにデプロイするのはStrandsAgentsを利用しようと思います。このStrandsAgents、簡単に作成できるのでぜひ試してみて下さいね。
私も過去にStrandsAgetsの記事を書いていたのでよければご覧ください。
ですが手元で動いているエージェントは、そのままではBedrockの実行環境(Runtime)に載りません。ここでは既存コードをほとんど変えずに、AgentCoreのSDKでHTTPエンドポイント化し、Runtimeに持ち込める形にします。
from strands import Agent
agent = Agent()
agent("JAWS-UGについて教えて")
以下のコマンドできますので、一旦動作を確認してみて下さい。
uv run runtime_ex.py
では、上記で作成したコードをAgentCore仕様に変更していきたいと思います。
また、他にも追加で作成必要なファイルがあるので以下にまとめます。
プロジェクト直下/
├── runtime_ex.py # エージェントのコードが書いてあるコード
├── requirements.txt # 依存関係をここに記述
└── __init__.py # これは空っぽでOK
strands-agents
bedrock-agentcore
エージェントのコードを以下のように変更します。
from strands import Agent
from bedrock_agentcore.runtime import BedrockAgentCoreApp
agent = Agent()
app = BedrockAgentCoreApp()
@app.entrypoint
def invoke(payload):
user_message = payload.get("prompt", "")
response = agent(user_message)
return str(response)
if __name__ == "__main__":
app.run()
- @app.entrypoint は Runtimeが呼び出す関数を登録するためのデコレータです。
BedrockのRuntimeは、ここで指定された関数を実行して結果を受け取ります。
@app.entrypoint
def invoke(payload):
"""Process user input and return a response"""
user_message = payload.get("prompt", "")
response = agent(user_message)
return str(response)
ここまでで、一通りのものは作成できたので、実際にAgentCoreにデプロイしていきます。
まず下記のコマンドでエージェントをRuntimeにデプロイする前の準備を行っています。
uv run agentcore configure --entrypoint runtime_ex.py
上記のコマンドでは冒頭の画像の、枠線で囲んだ以下の部分を実施しています。
また、このタイミングで以下のファイルが自動生成されます。
- Dockerfile
- .bedrock_agentcore.yaml
- .dockerignore
コマンド実施後選択肢が色々出てきますが基本全部Enter連打でOKです。
これによって
- IAMロール
- ECRリポジトリ
などが勝手に作成してくれます。
Configuring Bedrock AgentCore...
Entrypoint parsed: file=/Users/hogehoge/Desktop/strands/runtime_ex.py, bedrock_agentcore_name=runtime_ex
Agent name: runtime_ex
🔐 Execution Role
Press Enter to auto-create execution role, or provide execution role ARN/name to use existing
Previously configured: arn:aws:iam::hogehoge:role/AmazonBedrockAgentCore
Execution role ARN/name (or press Enter to auto-create):
✓ Will auto-create execution role
🏗️ ECR Repository
Press Enter to auto-create ECR repository, or provide ECR Repository URI to use existing
Previously configured: hogehoge.dkr.ecr.us-west-2.amazonaws.com/bedrock-agentcore-agent_core
ECR Repository URI (or press Enter to auto-create):
✓ Will auto-create ECR repository
🔍 Detected dependency file: requirements.txt
Press Enter to use this file, or type a different path (use Tab for autocomplete):
Path or Press Enter to use detected dependency file:
✓ Using detected file: requirements.txt
🔐 Authorization Configuration
By default, Bedrock AgentCore uses IAM authorization.
Configure OAuth authorizer instead? (yes/no) [no]:
✓ Using default IAM authorization
🔒 Request Header Allowlist
Configure which request headers are allowed to pass through to your agent.
Common headers: Authorization, X-Amzn-Bedrock-AgentCore-Runtime-Custom-*
Configure request header allowlist? (yes/no) [no]:
✓ Using default request header configuration
Configuring BedrockAgentCore agent: runtime_ex
🧠 Memory Configuration
✅ MemoryManager initialized for region: us-west-2
Existing memory resources found:
1. hogehoge
ID: hogehoge
2. hogehoge
ID: hogehogenJl
Options:
• Enter a number to use existing memory
• Press Enter to create new memory
• Type 's' to skip memory setup
Your choice:
🧠 Memory Configuration
✓ Short-term memory is enabled by default
• Stores conversations within sessions
• Provides immediate context recall
Optional: Long-term memory
• Extracts user preferences across sessions
• Remembers facts and patterns
• Creates session summaries
• Note: Takes 60-90 seconds to process
Enable long-term memory extraction? (yes/no) [no]:
✓ Using short-term memory only
Will create new memory with mode: STM_ONLY
Memory configuration: Short-term memory only
Generated Dockerfile: /Users/hogehoge/Desktop/strands/Dockerfile
Generated .dockerignore: /Users/hogehoge/Desktop/strands/.dockerignore
Changing default agent from 'agent_core' to 'runtime_ex'
╭─────────────────────────────────────────────────────────── Configuration Success ────────────────────────────────────────────────────────────╮
│ Configuration Complete │
│ │
│ Agent Details: │
│ Agent Name: runtime_ex │
│ Runtime: Docker │
│ Region: us-west-2 │
│ Account: hogehoge │
│ │
│ Configuration: │
│ Execution Role: None │
│ ECR Repository: Auto-create │
│ Authorization: IAM (default) │
│ │
│ │
│ Memory: Short-term memory (30-day retention) │
│ │
│ 📄 Config saved to: /Users/hogehoge/Desktop/strands/.bedrock_agentcore.yaml │
│ │
│ Next Steps: │
│ agentcore launch │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ここまでで準備完了しているので、
いよいよエージェントをRuntimeにデプロイします。
ここではconfigureコマンドで準備した設定ファイルをCodeBuild上でビルドしています。
以下のコマンドを実施し、AgentCoreに乗せてあげます。
実施後のログを見ると、ビルドも完了しagentcore invokeをしてくれ〜と言っていますね。
uv run agentcore launch
このコマンドでは以下の枠線の部分を実施します。
🚀 Launching Bedrock AgentCore (codebuild mode - RECOMMENDED)...
• Build ARM64 containers in the cloud with CodeBuild
• No local Docker required (DEFAULT behavior)
• Production-ready deployment
💡 Deployment options:
• agentcore launch → CodeBuild (current)
• agentcore launch --local → Local development
• agentcore launch --local-build → Local build + cloud deploy
Creating memory resource for agent: runtime_ex
✅ MemoryManager initialized for region: us-west-2
⠙ Launching Bedrock AgentCore...Creating new STM-only memory...
⠋ Launching Bedrock AgentCore...Created memory: runtime_ex_mem-eyH8CX2jlV
✅ New memory created: runtime_ex_mem-eyH8CX2jlV (provisioning in background)
Starting CodeBuild ARM64 deployment for agent 'runtime_ex' to account hogehoge (us-west-2)
⠙ Launching Bedrock AgentCore...Setting up AWS resources (ECR repository, execution roles)...
Getting or creating ECR repository for agent: runtime_ex
Repository doesn't exist, creating new ECR repository: hogehoge
⠹ Launching Bedrock AgentCore...✅ ECR repository available: hogehoge.dkr.ecr.us-west-2.amazonaws.com/bedrock-agentcore-runtime_ex
Getting or creating execution role for agent: runtime_ex
Using AWS region: us-west-2, account ID: hogehoge
Role name: hogehoge
⠙ Launching Bedrock AgentCore...Role doesn't exist, creating new execution role: hogehoge
⠹ Launching Bedrock AgentCore...Starting execution role creation process for agent: runtime_ex
✓ Role creating: hogehoge
Creating IAM role: hogehoge
⠴ Launching Bedrock AgentCore...✓ Role created: arn:aws:iam::hogehoge
⠋ Launching Bedrock AgentCore...✓ Execution policy attached: hogehogeBedrockAgentCoreRuntimeExecutionPolicy-runtime_ex
Role creation complete and ready for use with Bedrock AgentCore
✅ Execution role available: arn:aws:iam::hogehoge:role/AmazonBedrockAgentCoreSDKRuntime-us-west-2-d69978d78f
Preparing CodeBuild project and uploading source...
⠏ Launching Bedrock AgentCore...Getting or creating CodeBuild execution role for agent: runtime_ex
Role name: hogehoge
⠇ Launching Bedrock AgentCore...CodeBuild role doesn't exist, creating new role: AmazonBedrockAgentCoreSDKCodeBuild-us-west-2-d69978d78f
Creating IAM role: AmazonBedrockAgentCoreSDKCodeBuild-us-west-2-d69978d78f
⠏ Launching Bedrock AgentCore...✓ Role created: arn:aws:iam::hogehoge:role/AmazonBedrockAgentCoreSDKCodeBuild-us-west-2-d69978d78f
Attaching inline policy: CodeBuildExecutionPolicy to role: AmazonBedrockAgentCoreSDKCodeBuild-us-west-2-d69978d78f
⠸ Launching Bedrock AgentCore...✓ Policy attached: CodeBuildExecutionPolicy
Waiting for IAM role propagation...
⠇ Launching Bedrock AgentCore...CodeBuild execution role creation complete: arn:aws:iam::hogehoge:role/AmazonBedrockAgentCoreSDKCodeBuild-us-west-2-d69978d78f
⠸ Launching Bedrock AgentCore...Using .dockerignore with 44 patterns
⠋ Launching Bedrock AgentCore...Uploaded source to S3: runtime_ex/source.zip
⠏ Launching Bedrock AgentCore...Created CodeBuild project: bedrock-agentcore-runtime_ex-builder
Starting CodeBuild build (this may take several minutes)...
⠴ Launching Bedrock AgentCore...Starting CodeBuild monitoring...
⠇ Launching Bedrock AgentCore...🔄 QUEUED started (total: 0s)
⠸ Launching Bedrock AgentCore...✅ QUEUED completed in 1.2s
🔄 PROVISIONING started (total: 1s)
⠏ Launching Bedrock AgentCore...✅ PROVISIONING completed in 9.3s
🔄 DOWNLOAD_SOURCE started (total: 11s)
⠸ Launching Bedrock AgentCore...✅ DOWNLOAD_SOURCE completed in 1.2s
🔄 BUILD started (total: 12s)
⠏ Launching Bedrock AgentCore...✅ BUILD completed in 14.1s
🔄 POST_BUILD started (total: 26s)
⠹ Launching Bedrock AgentCore...✅ POST_BUILD completed in 5.8s
🔄 COMPLETED started (total: 32s)
⠧ Launching Bedrock AgentCore...✅ COMPLETED completed in 1.2s
🎉 CodeBuild completed successfully in 0m 32s
CodeBuild completed successfully
✅ CodeBuild project configuration saved
Deploying to Bedrock AgentCore...
Passing memory configuration to agent: runtime_ex_mem-eyH8CX2jlV
⠸ Launching Bedrock AgentCore...✅ Agent created/updated: arn:aws:bedrock-agentcore:us-west-2:017820658462:runtime/runtime_ex-JSXMBUGk3e
Observability is enabled, configuring Transaction Search...
⠙ Launching Bedrock AgentCore...CloudWatch Logs resource policy already configured
⠋ Launching Bedrock AgentCore...X-Ray trace destination already configured
⠹ Launching Bedrock AgentCore...X-Ray indexing rule already configured
✅ Transaction Search already fully configured
🔍 GenAI Observability Dashboard:
https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#gen-ai-observability/agent-core
Polling for endpoint to be ready...
⠦ Launching Bedrock AgentCore...Agent endpoint: arn:aws:bedrock-agentcore:us-west-2:hogehoge:runtime/runtime_ex-JSXMBUGk3e/runtime-endpoint/DEFAULT
Deployment completed successfully - Agent: arn:aws:bedrock-agentcore:us-west-2:hogehoge:runtime/runtime_ex-JSXMBUGk3e
╭───────────────────────────────────────────────────────────── Deployment Success ─────────────────────────────────────────────────────────────╮
│ ✅ CodeBuild Deployment Successful! │
│ │
│ Agent Details: │
│ Agent Name: runtime_ex │
│ Agent ARN:hogehoge │
│ ECR URI: hogehoge.dkr.ecr.us-west-2.amazonaws.com/bedrock-agentcore-runtime_ex:latest │
│ CodeBuild ID: hogehoge │
│ │
│ 🚀 ARM64 container deployed to Bedrock AgentCore │
│ │
│ Next Steps: │
│ agentcore status │
│ agentcore invoke '{"prompt": "Hello"}' │
│ │
│ 📋 CloudWatch Logs: │
│ /aws/bedrock-agentcore/runtimes/runtime_ex-JSXMBUGk3e-DEFAULT --log-stream-name-prefix "2025/10/17/[runtime-logs]" │
│ /aws/bedrock-agentcore/runtimes/runtime_ex-JSXMBUGk3e-DEFAULT --log-stream-names "otel-rt-logs" │
│ │
│ 🔍 GenAI Observability Dashboard: │
│ https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#gen-ai-observability/agent-core │
│ │
│ ⏱️ Note: Observability data may take up to 10 minutes to appear after first launch │
│ │
│ 💡 Tail logs with: │
│ aws logs tail /aws/bedrock-agentcore/runtimes/runtime_ex-JSXMBUGk3e-DEFAULT --log-stream-name-prefix "2025/10/17/[runtime-logs]" --follow │
│ aws logs tail /aws/bedrock-agentcore/runtimes/runtime_ex-JSXMBUGk3e-DEFAULT --log-stream-name-prefix "2025/10/17/[runtime-logs]" --since │
│ 1h │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
動作確認
起動は以下のコマンドで実施できます。
今回はJAWS-UGについて聞いてみました。
uv run agentcore invoke '{"prompt": "JAWS-UGについて教えて"}'
レスポンスはこちら。
Response:
{"result": {"role": "assistant", "content": [{"text": "JAWS-UGは、日本AWSユーザグループ(Japan AWS User Group)の略称です。\n\n## 概要\n-
**正式名称**: Japan AWS User Group\n- **目的**: AWS(Amazon Web Services)を利用する日本のユーザー同士の情報交換・交流\n- **運営形態**:
コミュニティベースの非営利組織\n\n## 主な活動\n1. **勉強会・セミナー開催**\n - AWSの新サービス紹介\n - 実践的な技術セッション\n -
ハンズオン形式の学習会\n\n2. **地域支部活動**\n - 全国各地に支部が存在\n - 地域特性に応じたイベント開催\n\n3. **オンライン活動**\n -
Slack等でのコミュニケーション\n - 情報共有・質問対応\n\n## 参加メリット\n- AWS技術者とのネットワーキング\n- 最新のAWS情報の入手\n-
実務経験の共有\n- キャリア開発の機会\n\n## 参加方法\n- 公式サイトやSNSで情報確認\n- 勉強会への参加登録\n-
オンラインコミュニティへの参加\n\nJAWS-UGは、AWSを学びたい初心者から上級者まで幅広い層が参加する、日本最大級のAWSコミュニティの一つです。"}]}}
ログの確認
これはAmazon Bedrock AgentCoreの機能である、GenAI Observabilityを利用するとわかりやすいです。
CloudWatchのコンソールに移動すると、以下のようにGenAI Observabilityが追加されています。
しれっとプレビュー期間中にはなかったModel Invocationが生えてました。
ダッシュボード上では、先ほどRuntimeで処理されたもののログを追うことができます。
今回はシンプルにLLMに問い合わせるだけですが、どのよう経路で処理をしていったのかなども見ることもできます。
これは複数のエージェントなんかを連携させる構成の場合はいいかもしれません。
また、その下ではより詳細な処理のログを確認できます。
今回は問題なく処理が完了しましたが、エラーが出た時などデバックがかなりやりやすそうですね。
課金体系
基本的に使った分だけ課金されます。
CPU:$0.0895/vCPU時間
メモリ:$0.00945/GB時間
詳しくは以下公式サイトを参照ください
さいごに
今回は、Amazon Bedrock AgentCore を使って、自作エージェントを Runtime にデプロイして実行できるようにするまでの流れを紹介しました。
手順も本当にシンプルで本当にこれでいいの!?と思ってしまうほどです。
ただ、一度流れを掴んでしまえば、Strands などで作ったエージェントをそのまま Bedrock 上に載せて動かせるようになり、「開発 → テスト → 実運用」までを一貫してマネージドに扱えるのが大きな魅力です。
この記事が、これから AgentCore Runtime を触ってみたい方の参考になれば幸いです。






