This example demonstrates how to integrate a LangGraph agent with AWS Bedrock AgentCore, enabling you to deploy a web search-capable agent as a managed service.
## Prerequisites
- Python 3.10+
- [uv](https://github.com/astral-sh/uv) - Fast Python package installer and resolver
- AWS account with Bedrock access
## Setup Instructions
### 1. Create a Python Environment with uv
```bash
# Install uv if you don't have it already
pip install uv
# Create and activate a virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
### 2. Install Requirements
```bash
uv pip install -r requirements.txt
```
### 3. Understanding the Agent Code
The `langgraph_agent_web_search.py` file contains a LangGraph agent with web search capabilities, integrated with Bedrock AgentCore:
```python
from typing import Annotated
from langchain.chat_models import init_chat_model
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode, tools_condition
# Initialize the LLM with Bedrock
llm = init_chat_model(
"us.anthropic.claude-3-5-haiku-20241022-v1:0",
model_provider="bedrock_converse",
)
# Define search tool
from langchain_community.tools import DuckDuckGoSearchRun