| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
A minimal LangGraph agent demonstrating core AgentCore concepts using code deployment.
Alternative: See langgraph-basic-docker for the same agent using Docker/container deployment.
User Request → AgentCore Runtime → agent_invocation()
↓
LangGraph
↓
Claude Sonnet 5
↓
(uses built-in tools)
↓
Response
Important: This example uses the global cross-region inference profile for better availability and throughput. Direct model IDs may not support on-demand invocation.
# From this directory
serverless deployThe framework will:
Using the provided test script:
# Update RUNTIME_ARN in test-invoke.py first
python3 test-invoke.pyOr invoke programmatically with boto3:
import boto3
import json
import uuid
client = boto3.client('bedrock-agentcore', region_name='us-east-1')
response = client.invoke_agent_runtime(
agentRuntimeArn='YOUR_RUNTIME_ARN', # From deploy output
runtimeSessionId=str(uuid.uuid4()),
payload=json.dumps({"prompt": "What is 25 multiplied by 4?"}).encode()
)
# Parse response
result = json.loads(response['response'].read())
print(result)Important: You cannot invoke AgentCore runtimes directly via curl. You must use the AWS SDK with the bedrock-agentcore client and the invoke_agent_runtime API method.
Test locally before deploying:
serverless devagent.py implements a simple LangGraph agent:
START → chatbot → [decide: use tool or respond]
↑ ↓
└─── tools ←┘
The configuration specifies:
Dependencies in requirements.txt are bundled automatically by AgentCore's code deployment packaging.
AgentCore automatically:
| Aspect | Code (this example) | Docker |
|---|---|---|
| Configuration | handler: agent.py | chatbot: {} |
| Dependencies | requirements.txt | pyproject.toml + Dockerfile |
| Build | Automatic packaging to S3 | Docker image to ECR |
| Runtime | AWS managed Python | Custom container |
| Languages | Python only | Any language |
| Setup | No Dockerfile needed | Dockerfile required |
The default model is global.anthropic.claude-sonnet-5, read from the MODEL_ID environment variable in agent.py. Override it via the MODEL_ID env var:
ai:
agents:
chatbot:
handler: agent.py
environment:
MODEL_ID: us.anthropic.claude-opus-4-1-20250805-v1:0 # Different modelAdd tools in agent.py using the @tool decorator:
from langchain_core.tools import tool
@tool
def search_database(query: str) -> str:
"""Search the product database."""
# Your database logic here
return f"Found products matching: {query}"
# Add to tools list
tools = [get_current_time, add, multiply, search_database]Add optional runtime configuration:
ai:
agents:
chatbot:
handler: agent.py
environment:
CUSTOM_VAR: value
lifecycle:
idleRuntimeSessionTimeout: 900 # Idle timeout (60-28800 seconds)
maxLifetime: 3600 # Max lifetime (60-28800 seconds)Remove all resources:
serverless remove| Back | FazBrowse Home | New Git URL |