Deep Agents と Bedrock AgentCore を活用した文脈豊かな研究エージェントの構築
AWS は LangChain の Deep Agents と連携し、Bedrock AgentCore を活用した孤立実行環境による深層リサーチエージェントの構築パターンを公開しました。
キーポイント
コンテキスト制限の解決策
LLM のコンテキストウィンドウ不足や処理競合を防ぐため、複雑なタスクを独立したサブエージェントに委譲し、簡潔な結果のみを取得するアーキテクチャが提案されています。
Bedrock AgentCore と Deep Agents の連携
LangChain Deep Agents がオーケストレーションを担当し、Amazon Bedrock AgentCore がブラウザマイクロVMやPython環境を提供するインフラとして機能する統合モデルが紹介されています。
並列リサーチと分析の実装例
複数の競合他社サイトを並列で調査するブラウザサブエージェントと、収集したデータからチャートやレポートを生成するアナリストサブエージェントによるエンドツーエンドのワークフローが実証されています。
管理型サービスとしての展開
開発者がローカル環境で試すだけでなく、AgentCore CLI を用いてセッション隔離された管理型サービスとして Bedrock AgentCore Runtime にデプロイする手順も示されています。
多様なワークフローへの適用可能性
本記事で紹介された並列データ収集、専門処理、合成のパターンは、競合調査以外にもデューデリジェンス、コンテンツ作成、データパイプラインのオーケストレーションなど幅広いユースケースに応用可能です。
管理型サービスとしてのデプロイ
AgentCore CLI を使用して AgentCore Runtime にエージェントをデプロイすることで、セッションごとの分離、安定したエンドポイント、組み込みの観測機能を持つ管理型サービスとして運用できます。
リソースの自動クリーンアップ
ブラウザセッションは 1 時間、インタープリターセッションは 15 分で自動的に期限切れとなり、不要になった AgentCore Memory リソースはコンソールまたは API を介して手動で削除できます。
影響分析・編集コメントを表示
影響分析
この記事は、単なる LLM の利用を超えて、複雑なタスクを安全に実行するための「エージェント・オーケストレーション」の実用的な標準化を示唆しています。特に、ブラウザやコード実行環境をマイクロVMで隔離するアプローチは、AI エージェントの信頼性とスケーラビリティを高める重要なステップであり、企業レベルでの自律型リサーチシステムの構築指針として大きな影響を与えるでしょう。
編集コメント
コンテキストの限界に直面する開発者にとって、サブエージェントによる分業とクラウドネイティブな実行環境の提供は、実装のハードルを大幅に下げる画期的なアプローチです。
AI を活用した研究ワークフローにおける一般的な課題は、深さと文脈のバランスです。エージェントが 10 のウェブページを読み込むと、そのコンテキストウィンドウ(大規模言語モデル (LLM) が一度に処理できるテキスト量)が生データで埋め尽くされてしまいます。また、データ分析コードを実行する場合、チャート生成ロジックが限られたスペースを巡って戦略的思考と競合することになります。チームは通常、手動のプロンプト連鎖や逐次処理によってこの課題に対処しています。
より良いアプローチは、深い作業を孤立したサブエージェントに委譲し、簡潔な結果のみを取得させることです。LangChain Deep Agents はこのオーケストレーションを担い、専門的な一時的なサブエージェントを起動してそのライフサイクルを管理します。Amazon Bedrock AgentCore は、各サブエージェントが必要とするインフラストラクチャを提供します。これには、ウェブ調査用のマイクロ VM(軽量で単一目的の仮想マシン)内のリアルブラウザと、データ分析用の完全な Python 環境が含まれます。AgentCore はまた、Deep Agents CLI のネイティブサンドボックスプロバイダーとしても利用可能であり、deepagents --sandbox agentcore を実行することで、フルエージェントを構築せずに AgentCore CodeInterpreter(コード解釈器)を試すことができます。
本記事では、このパターンをエンドツーエンドで実演する競争調査エージェントの構築方法について解説します。このチュートリアルは、マルチステップ AI ワークフローを開発中で、エージェントに隔離された実行環境が必要な開発者向けです。ノートブックの第 2 部では、AgentCore CLI を使用して、同じエージェントを Bedrock AgentCore Runtime にデプロイし、管理されたセッション隔離サービスとして実行できるようにします。
構築するもの
コーディネーターエージェントはリクエストを受け取ると、まず AgentCore Memory を確認して過去の調査インサイトを取得します。その後、3 つのブラウザサブエージェントを並列で起動し、それぞれが独自の AgentCore Browser MicroVM 内で異なる競合他社のウェブサイトをナビゲートして調査を行います。3 つのエージェントから構造化された発見結果が返されると、アナリストサブエージェントが統合データを取得し、AgentCore Code Interpreter を使用して比較チャートと Markdown レポートを生成します。最後に、重要なインサイトは将来のセッションのために AgentCore Memory に保存されます。このワークフロー全体は、Amazon CloudWatch を通じて Amazon Bedrock AgentCore Observability または LangSmith で追跡可能です。
各サブエージェントタイプは、その固有のツールセットのみへのアクセスを制限されます。研究者にはブラウザ用ツール、アナリストにはインタプリタ用ツール、コーディネーターにはメモリ用ツールが割り当てられます。
image図 1: LangChain Deep Agents オーケストレーター、Amazon Bedrock AgentCore ブラウザマイクロ VM、インタプリタ、メモリ、および CloudWatch または LangSmith トレーシング間のデータフローを示すソリューションアーキテクチャ。
以下のセクションでは、各コンポーネントを順を追って解説します。
エージェントの構築
このエージェントを構築するには、モデルを設定し、各サブエージェントタイプごとにツールキットを作成し、LangChain Deep Agents を用いてこれらを接続します。
前提条件
開始前に、以下の事項が揃っていることを確認してください。
- Amazon Bedrock AgentCore のアクセス権限を有効にした AWS アカウント
- 環境変数(AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY、AWS_SESSION_TOKEN、AWS_REGION)または AWS コマンドラインインターフェース(AWS CLI)プロファイルとして設定された AWS 認証情報。必要な IAM 権限については、AgentCore の入門ガイドを参照してください。
- パッケージのインストールに pip または uv を使用した Python 3.11 以降
- (オプション)AgentCore の観測性トレースとスパンを表示するために Amazon CloudWatch トランザクション検索が有効になっていること
- (オプション)観測性用の LangSmith アカウント
- (オプション)少なくとも 1 つの抽出戦略(会話イベントからどの知識を抽出するかを決定するルール)が設定された AgentCore Memory リソース
- (オプション)完全な実装のための langchain-aws サンプルリポジトリ内の実行可能な Jupyter ノートブック
ステップ 1: モデルの設定
以下のコードは、エージェントをオーケストレーションする大規模言語モデル(LLM)を設定します。この例では、Amazon Bedrock を通じて Claude Sonnet にアクセスします:
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import create_browser_toolkit, create_code_interpreter_toolkit
from deepagents import create_deep_agent
from botocore.config import Config as BotoConfig
model = ChatBedrockConverse(
model="us.anthropic.claude-sonnet-4-6",
region_name="us-west-2",
config=BotoConfig(read_timeout=300),
)us. プレフィックスは、より高い可用性のためにクロスリージョン推論プロファイルを使用します。また、ベースモデル ID を直接使用することもできます。
ステップ 2: ブラウザツールキットの作成
各競合他社には独自の BrowserToolkit が割り当てられ、それぞれが独自に AgentCore Browser MicroVM をプロビジョニングします。並列実行される研究者間では完全な分離が保証されます。このツールキットは、LLM が単一のターンで複数のブラウザツール呼び出しを発行した場合の同時実行性を処理します:
COMPETITORS = [
("GitHub", "https://github.com/pricing"),
("GitLab", "https://about.gitlab.com/pricing"),
("Bitbucket", "https://www.atlassian.com/software/bitbucket/pricing"),
]
toolkits_to_cleanup = []
research_subagents = []
for company_name, company_url in COMPETITORS:
browser_toolkit, browser_tools = create_browser_toolkit(region="us-west-2")
browser_toolkit.session_manager.session_wait_timeout = 60.0
toolkits_to_cleanup.append(browser_toolkit)
research_subagents.append({
"name": f"research-{company_name.lower()}",
"description": f"{company_name} の情報を {company_url} を閲覧して調査します。",
"system_prompt": RESEARCHER_PROMPT,
"tools": browser_tools,
})
各マイクロVMは、Playwright(オープンソースのブラウザ自動化ライブラリ)を介してWebSocket経由で接続された実際のChromiumブラウザを実行しています。セッションは一時的なものであり、数秒で起動します。複数のツール呼び出しが並列実行される際にブラウザ操作に十分な時間を確保するため、session_wait_timeout は60 秒に設定されています(デフォルト:10 秒)。ブラウザツールには、navigate_browser、extract_text、click_element、type_text、scroll_page、extract_hyperlinks、wait_for_element が含まれています。
image 図 2: 3 つの異なるマイクロVM セッションIDは、各研究サブエージェントが独自の隔離されたAmazon Bedrock AgentCore ブラウザ環境で動作していることを確認しています。
ステップ 3: インタープリターツールの作成
アナリストサブエージェントは、AgentCore Code Interpreter(Python 環境を完全に備えた隔離されたマイクロVM)を使用します。この環境には pandas、matplotlib、numpy が事前にインストールされています:
ci_toolkit, ci_tools = await create_code_interpreter_toolkit(region="us-west-2")
toolkits_to_cleanup.append(ci_toolkit)
analyst_subagent = {
"name": "data-analyst",
"description": "競合他社のデータを分析し、チャートとレポートを生成する。",
"system_prompt": ANALYST_PROMPT,
"tools": ci_tools,
}
インタープリターツールには、execute_code、execute_command、write_files、read_files、list_files、upload_file、install_packages が含まれています。追加のライブラリが必要ですか?run time に install_packages ツールを使用して追加してください。
ステップ 4:セッション間メモリの追加(オプション)
コーディネーターエージェントは、長期記憶 API に直接アクセスする AgentCore Memory ツールを用いて、時間をかけて専門知識を蓄積することができます。
from bedrock_agentcore.memory import MemoryClient
from langchain_core.tools import tool
memory_client = MemoryClient(region_name="us-west-2")
@tool
def save_research_insights(insights: str, session_id: str = "default") -> str:
"""競争調査の洞察を AgentCore の長期記憶に保存する。"""
memory_client.create_event(
memory_id=memory_id, actor_id=actor_id, session_id=session_id,
messages=[
(f"これらの研究洞察を保存します:\n\n{insights}", "USER"),
("洞察が長期記憶に保存されました。", "ASSISTANT"),
],
)
return "洞察が保存され、長期記憶へ抽出されます。"
重要: 長期記憶の検索機能を有効にするには、AgentCore Memory リソース至少 1 つの抽出戦略(例:semanticMemoryStrategy)を構成しておく必要があります。戦略を設定しない場合、create_event は生イベントを保存するだけで、検索のために洞察が抽出されません。
エージェントが洞察を保存すると、AgentCore Memory の構成された戦略が自動的に背景で構造化された知識を抽出します。 subsequent な実行時には、エージェントは recall_past_research を使用してこの抽出済み知識を検索します。これにより、最初から再調査することなく、関連する事実や過去の発見事項を見つけることができます。
ステップ 5: エージェントの作成と実行
コンポーネントを接続し、エージェントを呼び出します:
agent = create_deep_agent(
model=model,
subagents=[*research_subagents, analyst_subagent],
tools=memory_tools,
system_prompt=COORDINATOR_PROMPT,
name="competitive-research-coordinator",
checkpointer=None, # シンプル化のため; セッションの再開には AgentCoreMemorySaver を使用
store=InMemoryStore(), # Deep Agents 用の内部ストレージ (AgentCore Memory とは別)
)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "GitHub、GitLab、Bitbucket の価格を比較してください"}]},
config={"configurable": {"thread_id": "session-1", "actor_id": "research-agent"}},
)
進行状況インジケーターとセッション表示を含む実行可能なノートブックは、関連するノートブックで利用可能です。Claude Sonnet を使用した場合の予想実行時間は 4〜6 分であり、これは 3 つのサイト全体にわたる実際のブラウザナビゲーション時間を反映したものです。同じ調査を順次処理する場合、最大 3 倍の時間がかかります。
エージェントの追跡とデバッグ
AgentCore Observability を利用すると、Amazon CloudWatch を通じて、このマルチエージェントアーキテクチャを可視化できます。AgentCore は OpenTelemetry (OTEL) 形式でトレースとスパンを出力するため、CloudWatch GenAI Observability ページ上で完全なオーケストレーション階層を確認できます。最上位にはコーディネーターの実行があり、その下に各研究用サブエージェントの子スパン、そして続く分析用サブエージェントが配置されます。各スパン内では、ツール呼び出しの入力・出力・タイミング・トークン使用量を確認でき、壁時計のタイミングから研究用サブエージェントが並列実行されたことを確認できます。また、ブラウザのナビゲーションやコードの実行に失敗した場合に、どのサブエージェントおよびどのツール呼び出しで問題が発生したかを特定することも可能です。アカウントごとに一度だけ設定を行う必要がありますので、トレースとスパンが利用可能になる前に CloudWatch Transaction Search を有効化してください。エージェントを AgentCore Runtime (パート 2) でホストする場合、ランタイムが自動的に OTEL でエージェントを計測するため、追加の設定は不要です。同じエージェントをランタイム外で実行する場合は、AWS Distro for OpenTelemetry (ADOT) SDK と LangChain のインスツルメンテーションライブラリをエージェントに追加してください。詳細については、Amazon Bedrock AgentCore Observability ドキュメント を参照してください。
これらのトレースの品質は、Amazon Bedrock AgentCore Evaluations を用いて評価することもできます。これには、ゴール達成率やツール選択精度などの組み込み評価器が用意されています。詳細については、AgentCore Evaluations のドキュメントをご参照ください。
お好みの場合は、LangSmith を用いてトレースを行うことも可能です。LangSmith を利用すれば、このマルチエージェントアーキテクチャのデバッグを支援するエンドツーエンドのトレーシングが得られます。自動トレーシングを有効にするには、以下の 3 つの環境変数を設定してください:
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY="your-langsmith-api-key"
export LANGCHAIN_PROJECT="competitive-research-agent"
関連するノートブックでは、このオプションについても取り上げられています。
なぜこのアーキテクチャが重要なのか
コンポーネントがどのように連携するかをご覧いただいたところで、なぜこのパターンが価値あるものとなるのかを説明します。
第一に、コーディネーターは高レベルな推論に集中したまま維持されます。各リサーチサブエージェントは内部で多段階のブラウジング処理を行い、簡潔なサマリーのみを返すため、コーディネーターのコンテキストは生ページコンテンツで埋め尽くされることなく、統合(シンセシス)のために利用可能となります。
第二に、機能間の明確な分離が得られます。各サブエージェントタイプは自身のツールへのアクセスのみを持ち、意図しないツールの使用リスクを低減し、デバッグをより焦点を絞ったものへと導きます。
第三に、リサーチの実行速度が向上します。3 つのブラウザによるリサーチタスクを並列実行し、それぞれを独立した AgentCore MicroVM 内で処理することで、逐次処理と比較して実質的な所要時間を短縮できます。
最後に、Amazon Bedrock AgentCore はモデル非依存かつフレームワーク非依存です。AgentCore のツール(Browser, Interpreter, Memory)は、それらをオーケストレーションするモデルが何であっても同じように動作します。モデルの切り替えは単一行の変更だけで可能です:
# デフォルト:Amazon Bedrock
from langchain_aws import ChatBedrockConverse
model = ChatBedrockConverse(model="us.anthropic.claude-sonnet-4-6", region_name="us-west-2")
# 代替案:Anthropic API を直接利用
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model="claude-sonnet-4-6")
# 代替案:Google Gemini
from langchain_google_genai import ChatGoogleGenerativeAI
model = ChatGoogleGenerativeAI(model="gemini-2.5-pro")
AgentCore Runtime 上でエージェントをホストする
構築したエージェントはノートブック上で動作しますが、これは開発には適しています。セッションごとの分離と安定した呼び出し ARN を持つ管理されたエンドポイントへ移行するには、Amazon Bedrock AgentCore Runtime 上でホストできます。AgentCore Runtime は ARM64 コンテナ内でエージェントをホストし、各セッションを最大 8 時間、専用のマイクロ VM で実行します。フレームワーク非依存であるため、Deep Agents のコーディネーター、並列ブラウザサブエージェント、およびアナリストサブエージェントはすべて変更なしで動作します。
AgentCore CLI は、4 つのステップでデプロイワークフローを処理します。まず agentcore create でプロジェクトのスキャフォールドを作成し、次に agent code を用いてテンプレートを更新し、agentcore deploy でデプロイを実行し、最後に agentcore invoke で呼び出します。デプロイ後、agentcore logs でログをストリーミングしたり、agentcore traces でトレースを検査したりできます。作業が完了したら、agentcore remove に続いて agentcore deploy を実行することで、プロビジョニングされたすべてのリソースを削除できます。
ノートブックのパート 2 では、これらの各ステップと、前提条件および IAM パーミッションについて順を追って説明します。
クリーンアップ
課金を避けるために、作成した AgentCore リソースをクリーンアップしてください:
# ブラウザセッションのクリーンアップ
for toolkit in browser_toolkits:
await toolkit.cleanup()
インタープリタセッションのクリーンアップ
await ci_toolkit.cleanup()
ブラウザセッションは 1 時間後に自動的に期限切れになります。インタープリタセッションは 15 分後に自動的に期限切れになります。付随するノートブックには、自動的に実行されるクリーンアップコードが含まれています。AgentCore Memory リソースを作成したが不要になった場合は、Amazon Bedrock AgentCore コンソールまたは API を介して削除できます。
結論と今後のステップ
この記事では、オーケストレーションに LangChain Deep Agents を、孤立したブラウザ自動化、コード解釈、永続的メモリに Amazon Bedrock AgentCore を使用した研究エージェントを構築しました。このエージェントは AgentCore CLI を用いて AgentCore Runtime にデプロイされ、セッションごとの分離機能、安定したエンドポイント、組み込みの観測機能を備えた管理サービスとして実行されています。この並列データ収集、専門的な処理、合成のパターンは、競合調査以外の多くのワークフローにも適用可能です:
- 実務調査(Due diligence): サブエージェントを構成して、対象企業の財務報告書、プレスリリース、規制文書を調査します。例えば、競合他社の URL を SEC EDGAR の提出ページに置き換え、最小限の変更で同じブラウザサブエージェントパターンを再利用できます。
- コンテンツ作成:研究用サブエージェントで素材を集めながら、執筆用サブエージェントがセクションの草案を作成します。
- データパイプラインのオーケストレーション: サブエージェントが異なるソースからデータを抽出し、結合や変換のために統合された結果を分析担当のサブエージェントに渡します。
始めるには、同梱のノートブック を開き、セルごとの手順に従ってください。このソリューションについて質問やフィードバックがある場合は、この記事にコメントを残してください。このソリューションについて質問やフィードバックがある場合は、この記事にコメントを残してください。
本記事で使用されたサービスに関する詳細情報は、以下のドキュメントをご参照ください:
- LangChain Deep Agents ドキュメンテーション
- Amazon Bedrock AgentCore ドキュメンテーション
- Amazon Bedrock AgentCore の料金プラン
<a href="https://docs.langchain.com/langsmith/home" target="_blank" re
原文を表示
A common challenge in AI-powered research workflows is depth versus context. If your agent reads ten web pages, its context window (the amount of text a large language model (LLM) can process at once) gets filled with raw content. If it also runs data analysis code, chart-generation logic competes with strategic reasoning for limited space. Teams typically work around this with manual prompt-chaining or sequential processing.
A better approach is to delegate deep work to isolated subagents that return only concise results. LangChain Deep Agents handles this orchestration, spawning specialized ephemeral subagents and managing their lifecycle. Amazon Bedrock AgentCore provides the infrastructure each subagent needs. This includes a real browser in a MicroVM (a lightweight, single-purpose virtual machine) for web research and a full Python environment for data analysis. AgentCore is also available as a native sandbox provider in the Deep Agents CLI, so you can run deepagents --sandbox agentcore to try AgentCore CodeInterpreter without building a full agent.
In this post, you’ll build a competitive research agent that demonstrates this pattern end to end. This walkthrough targets developers building multi-step AI workflows who need isolated execution environments for their agents. In Part 2 of the notebook, you can deploy this same agent to Bedrock AgentCore Runtime using the AgentCore CLI, so it runs as a managed, session-isolated service.
What you’ll build
Your coordinator agent receives the request and first checks AgentCore Memory for past research insights. It then spawns three browser subagents in parallel for research, each navigating a different competitor’s website in its own AgentCore Browser MicroVM. When the three return structured findings, an analyst subagent receives the combined data and uses an AgentCore Code Interpreter to generate a comparison chart and markdown report. Finally, key insights are saved to AgentCore Memory for future sessions. You can trace the entire workflow with Amazon CloudWatch through Amazon Bedrock AgentCore Observability or LangSmith.
Each subagent type accesses only its specific set of tools: browser tools for the researchers, interpreter tools for the analyst, and memory tools for the coordinator.

Figure 1: Solution architecture showing the data flow between the LangChain Deep Agents orchestrator, Amazon Bedrock AgentCore Browser MicroVMs, Interpreter, Memory, and CloudWatch or LangSmith tracing.
The following sections walk through each component step by step.
Build the agent
To build this agent, you configure a model, create toolkits for each subagent type, and wire them together with LangChain Deep Agents.
Prerequisites
Before you begin, verify that you have the following:
- An AWS account with Amazon Bedrock AgentCore access enabled
- AWS credentials configured as environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_REGION) or via AWS Command Line Interface (AWS CLI) profile. For required IAM permissions, refer to the AgentCore getting-started guide.
- Python 3.11 or later with pip or uv for package installation
- (Optional) Amazon CloudWatch Transaction Search enabled to view AgentCore Observability traces and spans
- (Optional) A LangSmith account for observability
- (Optional) An AgentCore Memory resource with at least one extraction strategy configured (a rule that determines what knowledge to extract from conversation events)
- (Optional) A runnable Jupyter notebook in the langchain-aws samples repository for the complete implementation
Step 1: Set up the model
The following code configures the LLM that orchestrates your agent. This example accesses Claude Sonnet through Amazon Bedrock:
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import create_browser_toolkit, create_code_interpreter_toolkit
from deepagents import create_deep_agent
from botocore.config import Config as BotoConfig
model = ChatBedrockConverse(
model="us.anthropic.claude-sonnet-4-6",
region_name="us-west-2",
config=BotoConfig(read_timeout=300),
)The us. prefix uses a cross-region inference profile for higher availability. You can also use the base model ID directly.
Step 2: Create browser toolkits
Each competitor gets its own BrowserToolkit, which provisions its own AgentCore Browser MicroVM. You get complete isolation between parallel researchers. The toolkit handles concurrency when the LLM emits multiple browser tool calls in a single turn:
COMPETITORS = [
("GitHub", "https://github.com/pricing"),
("GitLab", "https://about.gitlab.com/pricing"),
("Bitbucket", "https://www.atlassian.com/software/bitbucket/pricing"),
]
toolkits_to_cleanup = []
research_subagents = []
for company_name, company_url in COMPETITORS:
browser_toolkit, browser_tools = create_browser_toolkit(region="us-west-2")
browser_toolkit.session_manager.session_wait_timeout = 60.0
toolkits_to_cleanup.append(browser_toolkit)
research_subagents.append({
"name": f"research-{company_name.lower()}",
"description": f"Researches {company_name} by browsing {company_url}.",
"system_prompt": RESEARCHER_PROMPT,
"tools": browser_tools,
})Each MicroVM runs a real Chromium browser connected through WebSocket using Playwright (an open source browser automation library). Sessions are ephemeral and spin up in seconds. The session_wait_timeout is set to 60 seconds (default: 10 seconds) to give browser operations enough time to finish when multiple tool calls run concurrently. The browser tools include navigate_browser, extract_text, click_element, type_text, scroll_page, extract_hyperlinks, and wait_for_element.

Figure 2:Three distinct MicroVM session IDs confirm that each research subagent operates in its own isolated Amazon Bedrock AgentCore Browser environment.
Step 3: Create the interpreter toolkit
The analyst subagent uses AgentCore Code Interpreter, an isolated MicroVM running a full Python environment with pandas, matplotlib, and numpy pre-installed:
ci_toolkit, ci_tools = await create_code_interpreter_toolkit(region="us-west-2")
toolkits_to_cleanup.append(ci_toolkit)
analyst_subagent = {
"name": "data-analyst",
"description": "Analyzes competitor data, generates charts and reports.",
"system_prompt": ANALYST_PROMPT,
"tools": ci_tools,
}The interpreter tools include execute_code, execute_command, write_files, read_files, list_files, upload_file, and install_packages. Need additional libraries? Use the install_packages tool to add them at runtime.
Step 4: Add cross-session memory (optional)
The coordinator agent can accumulate expertise over time with AgentCore Memory tools that interact with the long-term memory API directly:
from bedrock_agentcore.memory import MemoryClient
from langchain_core.tools import tool
memory_client = MemoryClient(region_name="us-west-2")
@tool
def save_research_insights(insights: str, session_id: str = "default") -> str:
"""Save competitive research insights to AgentCore long-term memory."""
memory_client.create_event(
memory_id=memory_id, actor_id=actor_id, session_id=session_id,
messages=[
(f"Save these research insights:\n\n{insights}", "USER"),
("Insights saved to long-term memory.", "ASSISTANT"),
],
)
return "Insights saved and are extracted into long-term memory."Important:Your AgentCore Memory resource must have at least one extraction strategy configured (such as semanticMemoryStrategy) for long-term recall to work. Without strategies, create_event stores raw events but no insights are extracted for retrieval.
When the agent saves insights, AgentCore Memory’s configured strategies automatically extract structured knowledge in the background. On subsequent runs, the agent uses recall_past_research to search this extracted knowledge. It finds relevant facts and past findings without re-researching from scratch.
Step 5: Create and run the agent
Wire the components together and invoke the agent:
agent = create_deep_agent(
model=model,
subagents=[*research_subagents, analyst_subagent],
tools=memory_tools,
system_prompt=COORDINATOR_PROMPT,
name="competitive-research-coordinator",
checkpointer=None, # Simplification; use AgentCoreMemorySaver for session resumability
store=InMemoryStore(), # Internal storage for Deep Agents (separate from AgentCore Memory)
)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "Compare pricing for GitHub, GitLab, and Bitbucket"}]},
config={"configurable": {"thread_id": "session-1", "actor_id": "research-agent"}},
)The runnable notebook with progress indicators and session display is available in the accompanying notebook. Expected runtime is 4–6 minutes with Claude Sonnet, reflecting real browser navigation time across three sites. Sequential processing of the same research would take up to 3x longer.
Trace and debug your agent
AgentCore Observability gives you visibility into this multi-agent architecture through Amazon CloudWatch. AgentCore emits traces and spans in OpenTelemetry (OTEL) format, so you can view the full orchestration hierarchy on the CloudWatch GenAI Observability page: the coordinator’s run at the top level, a child span for each research subagent, and the analyst subagent that follows. Within each span, you can review tool calls with their inputs, outputs, timing, and token usage, confirm that the research subagents ran concurrently from their wall-clock timing, and identify which subagent and tool call encountered an issue when a browser navigation or code run does not succeed. As a one-time setup per account, you enable CloudWatch Transaction Search before traces and spans become available. When you host the agent on AgentCore Runtime (Part 2), the runtime instruments your agent with OTEL automatically, so no additional configuration is needed. To run the same agent outside the runtime, add the AWS Distro for OpenTelemetry (ADOT) SDK and the LangChain instrumentation library to your agent. For more information, refer to the Amazon Bedrock AgentCore Observability documentation.
You can also score the quality of these traces with Amazon Bedrock AgentCore Evaluations, which provides built-in evaluators such as goal success rate and tool selection accuracy. For more details, refer to the AgentCore Evaluations documentation.
If you prefer, you can also use LangSmith for tracing. With LangSmith, you get end-to-end tracing that helps you debug this multi-agent architecture. Set three environment variables to turn on automatic tracing:
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY="your-langsmith-api-key"
export LANGCHAIN_PROJECT="competitive-research-agent"The accompanying notebook reviews this option.
Why this architecture matters
Now that you’ve seen how the components fit together, here’s why this pattern is valuable.
First, your coordinator stays focused on high-level reasoning. Each research subagent handles multi-step browsing internally and returns only a concise summary, keeping the coordinator’s context available for synthesis rather than filled with raw page content.
Second, you get clear separation between capabilities. Each subagent type accesses only its own tools, which reduces the chance of unintended tool usage and makes debugging more targeted.
Third, your research runs faster. Three browser research tasks run concurrently, each in its own AgentCore MicroVM, reducing wall-clock time compared to sequential processing.
Finally, Amazon Bedrock AgentCore is model-agnostic and framework-agnostic. The AgentCore tools (Browser, Interpreter, Memory) work identically regardless of which model orchestrates them. You can swap the model with a single line change:
# Default: Amazon Bedrock
from langchain_aws import ChatBedrockConverse
model = ChatBedrockConverse(model="us.anthropic.claude-sonnet-4-6", region_name="us-west-2")
# Alternative: Anthropic API directly
# from langchain_anthropic import ChatAnthropic
# model = ChatAnthropic(model="claude-sonnet-4-6")
# Alternative: Google Gemini
# from langchain_google_genai import ChatGoogleGenerativeAI
# model = ChatGoogleGenerativeAI(model="gemini-2.5-pro")Host the agent on AgentCore Runtime
The agent you built runs in a notebook, which works well for development. To move it to a managed endpoint with per-session isolation and a stable invocation ARN, you can host it on Amazon Bedrock AgentCore Runtime. AgentCore Runtime hosts your agent in an ARM64 container and runs each session in a dedicated microVM for up to 8 hours. Because it is framework-agnostic, your Deep Agents coordinator, the parallel browser subagents, and the analyst subagent all run unchanged.
The AgentCore CLI handles the deployment workflow in four steps: scaffold the project with agentcore create, update the template with your agent code, deploy with agentcore deploy, and invoke with agentcore invoke. After deployment, you can stream logs with agentcore logs and inspect traces with agentcore traces. When you are finished, agentcore remove all followed by agentcore deploy tears down all provisioned resources.
Part 2 of the notebook walks you through each of these steps, including prerequisites and IAM permissions.
Clean up
To avoid incurring charges, clean up the AgentCore resources you created:
# Clean up browser sessions
for toolkit in browser_toolkits:
await toolkit.cleanup()
# Clean up interpreter session
await ci_toolkit.cleanup()Browser sessions auto-expire after 1 hour. Interpreter sessions auto-expire after 15 minutes. The accompanying notebook includes cleanup code that runs automatically. If you created an AgentCore Memory resource and no longer need it, you can delete it through the Amazon Bedrock AgentCore console or API.
Conclusion and next steps
In this post, you built a research agent that uses LangChain Deep Agents for orchestration, Amazon Bedrock AgentCore for isolated browser automation, code interpretation, and persistent memory. You deployed the agent to AgentCore Runtime using AgentCore CLI to run it as a managed service with per-session isolation, a stable endpoint, and built-in observability. This pattern of parallel data gathering, specialized processing, and synthesis applies to many workflows beyond competitive research:
- Due diligence:Configure subagents to research financial filings, press releases, and regulatory documents for a target company. For example, swap the competitor URLs for SEC EDGAR filing pages and reuse the same browser subagent pattern with minimal changes.
- Content creation:Use research subagents to gather source material while a writing subagent drafts sections
- Data pipeline orchestration:Have subagents extract data from different sources, then pass combined results to an analyst subagent for joins and transformations
To get started, open the accompanying notebook and follow the cell-by-cell walkthrough. If you have questions or feedback about this solution, leave a comment on this post. If you have questions or feedback about this solution, leave a comment on this post.
For more information about the services used in this post, refer to:
- LangChain Deep Agents documentation
- Amazon Bedrock AgentCore documentation
- Amazon Bedrock AgentCore pricing
<a href="https://docs.langchain.com/langsmith/home" target="_blank" re
関連記事
Fireworks を活用した 100 倍安価なトレース判定器の構築
LangChain が Fireworks の技術を活用し、従来の 100 分の 1 のコストで動作するトレース判定器を開発したと発表した。
Meta の新「AI モード」が Facebook で公開情報を活用
Meta はFacebook に新機能「AI モード」を導入し、同社プラットフォーム全体から公開された情報を参照して回答を生成する機能を展開した。
Align Evals の紹介:LLM アプリケーション評価の効率化
LangChain が、大規模言語モデル(LLM)を用いたアプリケーションの評価プロセスを簡素化する新ツール「Align Evals」を発表した。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み