Agentcore RuntimeにClaude Agent SDK製エージェントをデプロイしてみた

Agentcore RuntimeにClaude Agent SDK製エージェントをデプロイしてみた

2026.04.21

はじめに

AI事業本部/生成AIインテグレーション部/ソリューションチームの竹口です。
Agentcore Runtime、いいですよね。
今回はAWSが提供するAIエージェント実行環境であるAgentcore Runtimeに、Claude Agent SDK製のAIエージェントをデプロイしてみました。

概要

AWSがAgentcore向けに推奨しているフレームワークはStrands Agentsですが、本記事ではAnthropicが提供するClaude Agent SDKを使用します。
両者の主な違いは以下の通りです。

  • Strands Agents:AWSネイティブ統合重視、Bedrockとの親和性が高い
  • Claude Agent SDK:Anthropic公式、Claudeの機能を直接活用できる

本記事の目的は「Claude Agent SDKでもAgentcore Runtimeにデプロイできる」ことを示すことなので、詳細な比較は別途記事にします。

Amazon Bedrock Agentcore

Amazon Bedrock Agentcoreとは、AIエージェントを展開・運用する上でうれしい機能が詰まった、AWSが提供するマネージドサービスです。
インフラ管理の煩わしさから解放されつつ、認証・ツール連携など現代のAIエージェントに必須の機能を簡単に実装することができます。

https://aws.amazon.com/jp/bedrock/agentcore/

弊社の神野さんが非常にわかりやすくまとめた記事を公開されています。本当に超わかりやすいので初心者の方にもおすすめです。

https://dev.classmethod.jp/articles/amazon-bedrock-agentcore-2025-summary/

Amazon Bedrock Agentcore Runtime

Amazon Bedrock Agentcore Runtimeは、AIエージェントをホスティングするためのマネージドサービスです。
イメージとしてはEC2やLambdaと近く、Runtimeサービスが提供するのは 実行環境 です。そのため、そこに実装するエージェントフレームワークやLLMモデルは自由に選択できます。

課金モデルも興味深く、アクティブなCPU とメモリの消費量に基づいて 1 秒単位で計算されます。
つまり、誰もセッションを繋いでいない(アイドル)状態の時間や、LLMの応答を待っている間のI/O待機時間は課金されません。

https://aws.amazon.com/jp/bedrock/agentcore/pricing/

Claude Agent SDK

Claude Agent SDKは、Claude製のAIエージェント構築フレームワークです。

ただのチャットbotとしてのAIではなく、ファイルの編集やコマンド実行など、自律的に作業を担い行動してくれる AIエージェント の構築を実に簡潔な数行の記述で実現できます。

Claude Codeを支えるツール、エージェントループ、コンテキスト管理機能を提供し、PythonとTypeScriptでプログラミング可能です。

https://code.claude.com/docs/en/agent-sdk/overview

やってみた

Claude Agent SDKでエージェントを作成

言語はPython、モデルはClaude Haiku 4.5を使用します。

https://code.claude.com/docs/en/agent-sdk/overview#python

uvで仮想環境を構築し、ライブラリをインストールします。

uv init
uv venv
uv pip install claude-agent-sdk 

Pythonバージョンは3.11としています。

.python-version
3.11

公式のクイックスタートを参考に、main.pyにエージェントを作成します。モデルは前述の通りClaude Haiku 4.5です。

main.py
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

async def main():
    options = ClaudeAgentOptions(
        allowed_tools=["Bash", "Glob"],
        permission_mode="acceptEdits",
        model="haiku",
    )

    async for message in query(
        prompt="What files are in this directory?", options=options
    ):
        if isinstance(message, ResultMessage):
            print(message.result or "")

asyncio.run(main())

実行後、結果が戻ってくればOKです。

実行結果
uv run main.py

現在のディレクトリには以下のファイルとフォルダがあります:
**Python プロジェクト関連:**
()

claude-agent-sdkは内部でClaude Code CLIをサブプロセスとして起動します。認証情報は claude login でログイン済みのセッション状態をそのまま使用します。

エージェントが作成できたら、これをRuntimeへデプロイしていきます。

Agentcore Runtimeへデプロイ

Agentcore Runtimeへデプロイするにあたって、モデルはBedrock経由で認証する形へ変更します。
また、デプロイ作業の前に以下の準備を済ませておきます。

  • aws cliの導入
  • aws login
  • Claude Haiku 4.5の基盤モデルアクセスの有効化

ライブラリをインストールします。

uv pip install bedrock-agentcore bedrock-agentcore-starter-toolkit

RuntimeがHTTPリクエストを受けた際、リクエストからプロンプトを取得してエージェントに渡して、その結果を返却する形にmain.pyを修正します。

main.py
import asyncio
import os

from bedrock_agentcore.runtime import BedrockAgentCoreApp
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

app = BedrockAgentCoreApp()

async def run_agent(prompt: str) -> str:
    options = ClaudeAgentOptions(
        allowed_tools=["Bash", "Glob"],
        permission_mode="acceptEdits",
        env={
            "CLAUDE_CODE_USE_BEDROCK": "1",
            "AWS_BEARER_TOKEN_BEDROCK": os.environ.get("BEDROCK_API_KEY", ""),
            "AWS_REGION": "ap-northeast-1",
        },
        model="jp.anthropic.claude-haiku-4-5-20251001-v1:0",
    )

    async for message in query(prompt=prompt, options=options):
        if isinstance(message, ResultMessage):
            return message.result or ""
    return ""

@app.entrypoint
def invoke(payload):
    user_message = payload.get("prompt", "")
    result = asyncio.run(run_agent(user_message))
    return {"result": result}

if __name__ == "__main__":
    app.run()

BedrockAgentCoreAppがHTTPサーバを立て、@app.entrypointがリクエストハンドラとなります。
invoke関数内ではリクエストからpromptを取得し、Claude Agent SDK製AIエージェントに渡し、結果をレスポンスとして返却します。

デプロイ&動作確認

デプロイに requirements.txt が必要になるため、事前に出力しておきます。

uv pip freeze > requirements.txt

Bedrock Agentcore Starter Toolkitを使用することで、実に簡潔にデプロイができます。
ターミナルで以下のコマンドを実行し、デプロイ設定を行います。

uv run agentcore configure -e main.py

するといくつかの選択が促されます。

Configuring Bedrock AgentCore...
 Using file: main.py

🏷️  Inferred agent name: main
Press Enter to use this name, or type a different one (alphanumeric without '-')
Agent name [main]: TestClaudeAgent
 Using agent name: TestClaudeAgent

🔍 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: requirements.txt
 Using requirements file: requirements.txt

🚀 Deployment Configuration
Select deployment type:
  1. Direct Code Deploy (recommended) - Python only, no Docker required
  2. Container - For custom runtimes or complex dependencies
Choice [1]: 1

Select Python runtime version:
  1. PYTHON_3_10
  2. PYTHON_3_11
  3. PYTHON_3_12
  4. PYTHON_3_13
Choice [2]: 2
 Deployment type: Direct Code Deploy (python.3.11)

🔐 Execution Role
Press Enter to auto-create execution role, or provide execution role ARN/name to
use existing
Execution role ARN/name (or press Enter to auto-create):
 Will auto-create execution role

🏗️  S3 Bucket
Press Enter to auto-create S3 bucket, or provide S3 URI/path to use existing
S3 URI/path (or press Enter to auto-create):
 Will auto-create S3 bucket

🔐 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: TestClaudeAgent

Memory Configuration
Tip: Use --disable-memory flag to skip memory entirely

No existing memory resources found in your account

Options:
 Press Enter to create new memory
 Type 's' to skip memory setup

Your choice: s
 Skipping memory configuration
Memory disabled by user choice
Network mode: PUBLIC
Changing default agent from 'TestAgent' to 'TestClaudeAgent'
╭───────────────────────────── Configuration Success ─────────────────────────────╮
 Agent Details
 Agent Name: TestClaudeAgent
 Deployment: direct_code_deploy
 Region: ap-northeast-1
 Account: <AWS Account ID>
 Runtime: python3.11

 Configuration
 Execution Role: Auto-create
 Network Mode: Public
 S3 Bucket: Auto-create
 Authorization: IAM (default)                                                    │


 Memory: Disabled


 📄 Config saved to:
 <cwd>/.bedrock_agentcore.yaml

 Next Steps:
 agentcore deploy
╰─────────────────────────────────────────────────────────────────────────────────╯

Agent name [main]:ではエージェントの名前を指定します。他の選択ではソースコード設置先のS3バケットや実行用IAMロールの指定を行いますが、Enterを押しておけばデフォルト値で自動作成を行ってくれます。
今回はAgentcore機能の内Runtimeのみを利用したいという意図から、Memory機能はオフに設定しています。

作業フォルダにセッティングファイルが作成されたら、早速エージェントをAWSへとデプロイします。
Claude製エージェントの認証情報の設定については、今回はBedrockの短期APIキーを取得してデプロイ時にenvで貼り付けます。

uv run agentcore deploy --env BEDROCK_API_KEY=<Bedrock 短期APIキ>

デプロイの完了時には、以下のような内容が出力されます。

╭─────────────────────────────────── Deployment Success ────────────────────────────────────╮
 Agent Details:
 Agent Name: TestClaudeAgent
 Agent ARN:
 arn:aws:bedrock-agentcore:ap-northeast-1:<AWS Account ID>:runtime/TestClaudeAgent-kh3U3vBOu4
 Deployment Type: Direct Code Deploy

 📦 Code package deployed to Bedrock AgentCore

 Next Steps:
    agentcore status
    agentcore invoke '{"prompt": "Hello"}'

 📋 CloudWatch Logs:
    /aws/bedrock-agentcore/runtimes/TestClaudeAgent-kh3U3vBOu4-DEFAULT
 --log-stream-name-prefix "2026/04/21/[runtime-logs"
    /aws/bedrock-agentcore/runtimes/TestClaudeAgent-kh3U3vBOu4-DEFAULT --log-stream-names
 "otel-rt-logs"

 🔍 GenAI Observability Dashboard:
    https://console.aws.amazon.com/cloudwatch/home?region=ap-northeast-1#gen-ai-observabil
 ity/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/TestClaudeAgent-kh3U3vBOu4-DEFAULT
 --log-stream-name-prefix "2026/04/21/[runtime-logs" --follow
    aws logs tail /aws/bedrock-agentcore/runtimes/TestClaudeAgent-kh3U3vBOu4-DEFAULT
 --log-stream-name-prefix "2026/04/21/[runtime-logs" --since 1h
╰───────────────────────────────────────────────────────────────────────────────────────────╯

agentcore invokeコマンドで呼び出してみます。

uv run agentcore invoke '{"prompt": "こんにちは!あなたは誰ですか?"}'

一秒前後でレスポンスが返ってきました。

uv run agentcore invoke '{"prompt": "こんにちは!あなたは誰ですか?"}'                                                                                ╭───────────────────────────────────── TestClaudeAgent ─────────────────────────────────────╮
 Session: <Session ID>
 Request ID: <Request ID>
 ARN:
 arn:aws:bedrock-agentcore:ap-northeast-1:<AWS Account ID>:runtime/TestClaudeAgent-kh3U3vBOu4
 Logs: aws logs tail /aws/bedrock-agentcore/runtimes/TestClaudeAgent-kh3U3vBOu4-DEFAULT
 --log-stream-name-prefix "2026/04/21/[runtime-logs" --follow
       aws logs tail /aws/bedrock-agentcore/runtimes/TestClaudeAgent-kh3U3vBOu4-DEFAULT
 --log-stream-name-prefix "2026/04/21/[runtime-logs" --since 1h
 GenAI Dashboard:
 https://console.aws.amazon.com/cloudwatch/home?region=ap-northeast-1#gen-ai-observability
 /agent-core
╰───────────────────────────────────────────────────────────────────────────────────────────╯

Response:
{"result":
"こんにちは!私はClaudeです。Anthropic社によって開発されたAIアシスタントです。\n\n私はコード
作成、デバッグ、分析、ドキュメント作成など、様々なタスクをお手伝いすることができます。また、
複雑なプロジェクトの計画立案や、既存のコードベースの改善についてもサポートします。\n\n何かお
手伝いできることがあればお知らせください!😊"}

Claude Agent SDK製のエージェントも、Runtime環境で問題なく動かすことができました。

おわりに

Agentcoreには他にも多くの機能が提供されており、特にエンタープライズ要件では必須となる統制・監査機能がIdentityやObservabilityなどで簡単に実装可能な点は、開発者として非常に嬉しいですね。
2025年11月のアップデートによって追加されたコードの直接デプロイを活用して今回のデプロイを行いましたが、コンテナ環境不要でRuntimeを立てられるようになったのは検証の容易さという点で開発者に優しいです。

本記事が誰かの役に立ちましたら幸いです。

参考文献

https://aws.amazon.com/jp/bedrock/agentcore/

https://dev.classmethod.jp/articles/amazon-bedrock-agentcore-2025-summary/

https://aws.amazon.com/jp/bedrock/agentcore/pricing/

https://code.claude.com/docs/en/agent-sdk/overview

https://code.claude.com/docs/en/agent-sdk/overview#python

https://dev.classmethod.jp/articles/amazon-bedrock-agentcore/

https://aws.amazon.com/jp/about-aws/whats-new/2025/11/amazon-bedrock-agentcore-runtime-code-deployment/

この記事をシェアする

関連記事