こんにちは。25年新入社員の高垣です。
私は、新人研修の一環として10月に開発合宿に参加しました。開発合宿については以下のブログをご覧ください。
その時に、2025/10/13(米国時間)に一般公開されたAmazon Bedrock AgentCoreを使って開発しました。このブログでは、その感想や実装について述べようと思います。
Amazon Bedrock AgentCoreとは
Amazon Bedrock AgentCore(以下AgentCore)とは、AIエージェントの構築からデプロイ・運用までできる基盤です。具体的には以下の7つのサービスがあります。
- Runtime: サーバレスの実行環境
- Identity: エージェントに対する認証情報(アウトバウンド・インバウンド両方)を管理するもの
- Memory: エージェントが何を記憶するかを制御する
- Code Interpreter: 分離されたサンドボックス環境内でコードを安全に実行する
- Browser: クラウドベースのブラウザ実行環境
- Gateway: APIやLambda関数などの既存のサービスをエージェント互換のツールへ簡単に変換する
- Observability: エージェントのモニタリング
どのように使用したのか
今回は実行環境としてRuntimeのみ使用しています。アプリケーション全体の構成は次の図のとおりです。Orchestratorエージェントはユーザからの入力を受け取り、Create_taskエージェントは入力に基づいたタスクを生成しています。詳細は以下のブログをご覧ください。

エージェントの中身について
2つのエージェントは役割が違いますが、中身はほとんど同じです。
両者共に、Bedrock AgentCore Runtimeフレームワークを使用してエージェントの振る舞いを定義しています。
例:Orchestratorエージェントの場合
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
@app.entrypoint def invoke(payload: Dict[str, Any]) -> str: try: # promptを読み取る request_text = payload.get("prompt", "") if not request_text: return json.dumps({ "status": "error", "message": "リクエストが指定されていません" }, ensure_ascii=False) # ユーザからの入力を分析し、適切なエージェントを決定 agent_decision = analyze_request(request_text) if agent_decision["action"] == "create_task": # Create_taskエージェントを呼び出す result = invoke_create_task_agentcore(request_text) # レスポンスを作る response = { "orchestrator_analysis": { "recommended_agent": agent_decision["agent"], "reason": agent_decision["reason"], "confidence": agent_decision["confidence"] }, "result": result } return json.dumps(response, ensure_ascii=False) |
@app.entrypointというデコレータでこの関数をAgentCore Runtimeのエントリーポイントとして登録しています。
Orchestratorエージェントの場合は、promptを読み取り、そこから適切なエージェントを決定して、エージェントに処理を投げています。
AIエージェントのフレームワークについては、最初に簡単な処理を作って動作を確認してからStrands AgentsかLangGraphを使おうと思っていました。ただ、時間がなかったので、今回はそれらは使用できませんでした(はじめからどちらかを使っておけばよかったと思っています…)。
デプロイについて
AWSのチュートリアルではコマンドを使ってデプロイしています。
https://aws.amazon.com/jp/blogs/startup/5min-ai-agent-hosting/
ですが、今回はPythonのSDKを使ってデプロイしました(Claude Codeに作ってもらいました)。
例:Orchestratorエージェントをデプロイするコード
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
import json import os import sys from pathlib import Path from bedrock_agentcore_starter_toolkit.notebook.runtime.bedrock_agentcore import Runtime # リージョン設定 REGION = "ap-northeast-1" PROJECT_NAME = "task-management" def deploy_orchestrator_agent(): """Orchestrator Agentをデプロイ""" print("\n🚀 Orchestrator Agent をデプロイ中...") # deployment_info.jsonからCreate Task AgentのARNを取得 deployment_file = Path(__file__).parent / "deployment_info.json" if not deployment_file.exists(): print("❌ deployment_info.jsonが見つかりません") print("先にCreate Task Agentをデプロイしてください:") sys.exit(1) with open(deployment_file, "r") as f: deployment_info = json.load(f) create_task_info = deployment_info.get("create_task_agent", {}) create_task_arn = create_task_info.get("agent_arn") if not create_task_arn: print("❌ Create Task AgentのARN情報が見つかりません") print("deployment_info.json:") print(json.dumps(deployment_info, indent=2, ensure_ascii=False)) sys.exit(1) print(f"✓ Create Task Agent ARN: {create_task_arn}") runtime = Runtime() # Orchestrator Agentの設定 config_result = runtime.configure( entrypoint="orchestrator/agent.py", agent_name="orchestrator_agent", requirements_file="orchestrator/requirements.txt", region=REGION, protocol="HTTP", memory_mode="NO_MEMORY", # メモリ不要 auto_create_execution_role=True, auto_create_ecr=True, disable_otel=False, # OpenTelemetry有効 non_interactive=True ) print(f"✓ 設定完了") print(f" Config: {config_result.config_path}") print(f" Dockerfile: {config_result.dockerfile_path}") # Bedrock AgentCore Runtimeにデプロイ(launch) print("📦 Bedrock AgentCore Runtimeにデプロイ中...") launch_result = runtime.launch( local=False, # リモートデプロイ local_build=False, auto_update_on_conflict=True, env_vars={ "CREATE_TASK_AGENT_ARN": create_task_arn, "AWS_REGION": REGION } ) print(f"✓ デプロイ完了") print(f" Agent ARN: {launch_result.agent_arn}") if hasattr(launch_result, 'agent_endpoint'): print(f" Agent Endpoint: {launch_result.agent_endpoint}") # デプロイ情報を更新 deployment_file = Path(__file__).parent / "deployment_info.json" with open(deployment_file, "r") as f: deployment_info = json.load(f) deployment_info["orchestrator_agent"] = { "agent_name": "orchestrator_agent", "agent_arn": launch_result.agent_arn, "agent_id": getattr(launch_result, 'agent_id', None), "agent_endpoint": getattr(launch_result, 'agent_endpoint', None), "status": "deployed", "create_task_agent_arn": create_task_arn } with open(deployment_file, "w") as f: json.dump(deployment_info, f, indent=2, ensure_ascii=False) print(f"\n💾 デプロイ情報を更新: {deployment_file}") return { "agent_name": "orchestrator_agent", "agent_arn": launch_result.agent_arn, "agent_id": getattr(launch_result, 'agent_id', None), "agent_endpoint": getattr(launch_result, 'agent_endpoint', None), "status": "deployed" } def main(): print("🚀 Orchestrator Agent デプロイスクリプト") print(f"Region: {REGION}") print(f"Project: {PROJECT_NAME}") print() try: orchestrator_info = deploy_orchestrator_agent() print("\n✅ Orchestrator Agent のデプロイが完了しました!") print(f"\nAgent ARN: {orchestrator_info['agent_arn']}") if orchestrator_info.get('agent_endpoint'): print(f"Agent Endpoint: {orchestrator_info['agent_endpoint']}") except Exception as e: print(f"\n❌ エラーが発生しました: {str(e)}") import traceback traceback.print_exc() sys.exit(1) if __name__ == "__main__": main() |
苦労したこと
情報が少ない
AgentCoreは2025年10月13日(米国時間)にリリースされましたが、その前にプレビューとして一部のリージョンで2025年7月16日に公開されていました。しかしながら、公開されてから3ヶ月弱しか期間がなく、AgentCoreに関する記事が十分にありませんでした。
そんな中でも、参考にしたサイトがいくつかあるので共有します。
Amazon Bedrock Agentsとの違いを理解する必要がある
AWSが提供しているAIエージェント系のサービスでAmazon Bedrock Agents(以下Bedrock Agents)というものがあります。
https://aws.amazon.com/jp/bedrock/agents/
こちらは、Amazon Bedrockの一部でLLMのモデルを指定するだけでAIエージェントを作成することができます。ただし、文字列のレスポンスを返したり、lambdaなどの関数を実行したりすることしかできないので、自由度は低めです。一方で、AgentCoreは実質Pythonコードを動かしているため、jsonを返したり、複雑な処理を実行することができます。この違いを理解しないと、開発途中で大きな手戻りが発生してしまう可能性があります。
今回の場合だと、初めはBedrock Agentsで開発していましたが、後から決まったレスポンスを返す必要があることがわかりました。いくらプロンプトを修正してもlambdaを実行してくれなかったり、lambdaへの入力が違ったりしたので、途中からAgentCoreを用いて開発しました。
参考程度に、Bedrock AgentsとAgentCoreの比較表を載せます。
| Bedrock Agents | AgentCore | |
| 役割 | AIエージェント | AIエージェントを実行する基盤 |
| 開発方法 | AWSマネジメントコンソール | Pythonコード(フレームワーク) |
| 料金 | Bedrockの料金体系 | AgentCoreの料金体系 |
| デプロイ | 不要 | SDKかAgentcore CLI |
AIエージェントを組み込んだプロダクトを作る際の前提知識が不足していた(わからなかった)
今回初めてAIエージェントを組み込んだプロダクトを作りましたが、前提知識が不足していたと思っています。理由としては、開発時に詰まった際に、「これがわからないからここを調べよう」というよりも、「ここがわからないけど、これはそもそもなんなんだ」と思うことが多くあったからです。前提知識がなく、時間があまりない中で調べながら開発したため、十分に開発することはできませんでした。
この経験から、前提知識として以下のようなものを知っておくことをおすすめします。
- AIエージェントを組み込んだプロダクトに対するブログや記事があるか
- 先駆者の知識や経験は非常に参考になると思います
- LangGraphや Strands Agentsなどのフレームワークについて
- フレームワークの名前だけ知っていても十分だと思います
- インフラについて
- AgentCore以外にもVertex AI Agent BuilderやAzure AI Foundry Agent Serviceなどの選択肢があります
- AIエージェントのデザインパターンについて
感想
AIエージェントを使ったサービスを作りたい際は、Bedrock Agentsに比べてAgentCoreの方が柔軟に開発できるので、AgentCoreを使った方が良いと思います。ただし、Bedrock Agentsの方が比較的簡単に作れるので、初めにBedrock Agentsでプロトタイプを作ってから、AgentCoreで本番開発をするという流れでも良いと思います。
また、AgentCoreはあくまでも基盤なので、フレームワーク等でAIを呼ぶ処理を書くようにしましょう(1敗)。
最後に、AgentCoreを使った開発は楽しかったです。AIエージェントの可能性を感じることができましたし、情報があまりない中で調べながら開発することはとてもワクワクしました。


