Production-ready multi-agent conversational AI system built with Bedrock AgentCore and Strands Agents. Supports RAG workflows, MCP-based tool integration, multimodal input/output, financial analysis tools, and deep research orchestration with prompt caching and multi-protocol tool execution.
Combines Strands Agent orchestration with AWS Bedrock AgentCore services:
- Strands Agent: Multi-turn conversation orchestration with tool execution
- AgentCore Runtime: Containerized agent deployment as managed AWS service
- AgentCore Memory: Persistent conversation storage with user preference retrieval
- AgentCore Gateway: MCP tool integration with SigV4 authentication
- AgentCore Code Interpreter: Built-in code execution for data analysis, visualization, and chart generation
- AgentCore Browser: Web automation via headless browser with live view streaming
- Amazon Nova Act: Agentic foundation model for browser automation with visual reasoning
-
Frontend + BFF (Next.js)
- Server-side API routes as Backend-for-Frontend
- Cognito authentication with JWT validation
- SSE streaming from AgentCore Runtime
- Session management and file upload handling
-
AgentCore Runtime
- Strands Agent with Bedrock Claude models
- Turn-based session manager (optimized message buffering)
- Uses AgentCore Memory for conversation persistence
- Integrates with AgentCore Gateway via SigV4
- Calls Built-in Tools via AWS API
- Communicates with other agents via A2A protocol (Work in Progress)
-
AgentCore Gateway
- MCP tool endpoints with SigV4 authentication
- Routes requests to 5 Lambda functions (12 tools total)
- Lambda functions use MCP protocol
- Tools: Wikipedia, ArXiv, Google Search, Tavily, Finance
-
AgentCore Memory
- Persistent conversation storage
- Automatic history management across sessions
-
Tool Ecosystem
- Local Tools: Weather, visualization, web search, URL fetcher (embedded in Runtime)
- Built-in Tools: AgentCore Code Interpreter for diagrams/charts, AgentCore Browser for automation (AWS SDK + WebSocket)
- Gateway Tools: Research, search, and finance data (via AgentCore Gateway + MCP)
- Runtime Tools (Work in Progress): Report Writer with A2A protocol
- Amazon Bedrock AgentCore Runtime
- Strands Agent Orchestration
- MCP Gateway Tools (Wikipedia, ArXiv, Google, Tavily)
- A2A Agent-to-Agent Protocol
- Financial research tools (stock data, market news)
- Multimodal I/O (Vision, Charts, Documents, Screenshots)
- Financial research agent with stock analysis & SEC ingestion
- Technical research assistant using multi-agent architecture
- Web automation agent via AgentCore Browser + Nova Act
- RAG-enabled chatbot using AgentCore Memory
- Multi-protocol research assistant (MCP, A2A, AWS SDK)
1. Full-stack Web-based Chatbot Application
- Frontend: Next.js with React, TypeScript, Tailwind CSS, shadcn/ui
- Backend (BFF): Next.js API routes for SSE streaming, authentication, session management
- Agent Runtime: Strands Agent orchestration on AgentCore Runtime (containerized)
- Persistence: AgentCore Memory for conversation history and user context
- Authentication: AWS Cognito with JWT validation
- Deployment: CloudFront β ALB β Fargate (Frontend+BFF) + AgentCore Runtime
2. Multi-Protocol Tool Architecture
Tools communicate via different protocols based on their characteristics:
| Tool Type | Protocol | Count | Examples | Authentication |
|---|---|---|---|---|
| Local Tools | Direct function calls | 5 | Weather, Web Search, Visualization | N/A |
| Built-in Tools | AWS SDK + WebSocket | 4 | AgentCore Code Interpreter, Browser (Nova Act) | IAM |
| Gateway Tools | MCP + SigV4 | 12 | Wikipedia, ArXiv, Finance (Lambda) | AWS SigV4 |
| Runtime Tools | A2A protocol | 9 | Report Writer | AgentCore auth |
Status: 21 tools β / 9 tools π§. See Implementation Details for complete tool list.
3. Dynamic Tool Filtering
Users can enable/disable specific tools via UI sidebar, and the agent dynamically filters tool definitions before each invocation, sending only selected tools to the model to reduce prompt token count and optimize costs.
4. Token Optimization via Prompt Caching
Implements hooks-based caching strategy with system prompt caching and dynamic conversation history caching (last 2 messages), using rotating cache points (max 4 total) to significantly reduce input token costs across repeated API calls.
5. Multimodal Input/Output
Native support for visual and document content:
- Input: Images (PNG, JPEG, GIF, WebP), Documents (PDF, CSV, DOCX, etc.)
- Output: Charts from AgentCore Code Interpreter, screenshots from AgentCore Browser
6. Two-tier Memory System
Combines session-based conversation history (short-term) with namespaced user preferences and facts (long-term) stored in AgentCore Memory, enabling cross-session context retention with relevance-scored retrieval per user.
See docs/TOOLS.md for detailed tool specifications.
| Tool Name | Protocol | API Key | Status | Description |
|---|---|---|---|---|
| Local Tools | ||||
| Calculator | Direct call | No | β | Mathematical computations |
| Weather Lookup | Direct call | No | β | Current weather by city |
| Visualization Creator | Direct call | No | β | Interactive charts (Plotly) |
| Web Search | Direct call | No | β | DuckDuckGo search |
| URL Fetcher | Direct call | No | β | Web content extraction |
| Built-in Tools | ||||
| Diagram Generator | AWS SDK | No | β | Charts/diagrams via AgentCore Code Interpreter |
| Browser Automation (3 tools) | AWS SDK + WebSocket | Yes | β | Navigate, action, extract via AgentCore Browser (Nova Act) |
| Gateway Tools | ||||
| Wikipedia (2 tools) | MCP + SigV4 | No | β | Article search and retrieval |
| ArXiv (2 tools) | MCP + SigV4 | No | β | Scientific paper search |
| Google Search (2 tools) | MCP + SigV4 | Yes | β | Web and image search |
| Tavily AI (2 tools) | MCP + SigV4 | Yes | β | AI-powered search and extraction |
| Financial Market (4 tools) | MCP + SigV4 | No | β | Stock quotes, history, news, analysis (Yahoo Finance) |
| Runtime Tools | ||||
| Report Writer (9 tools) | A2A | No | π§ | Multi-section research reports with charts |
Protocol Details:
- Direct call: Python function with
@tooldecorator, executed in runtime container - AWS SDK: Bedrock client API calls (AgentCore Code Interpreter, AgentCore Browser)
- WebSocket: Real-time bidirectional communication for browser automation
- MCP + SigV4: Model Context Protocol with AWS SigV4 authentication
- A2A: Agent-to-Agent protocol for runtime-to-runtime communication
Total: 30 tools (21 β / 9 π§)
Implementation: agent.py:277-318
# User-selected tools from UI sidebar
enabled_tools = ["calculator", "gateway_wikipedia-search___wikipedia_search"]
# Filters applied before agent creation
agent = Agent(
model=model,
tools=get_filtered_tools(enabled_tools), # Dynamic filtering
session_manager=session_manager
)Flow:
- User Toggle: User selects tools via UI sidebar
- Enabled Tools: Frontend sends enabled tool list to AgentCore Runtime
- Tool Filtering: Strands Agent filters tools before model invocation
- Invoke: Model receives only enabled tool definitions
- ToolCall: Agent executes local or remote tools as needed
Benefits:
- Reduced token usage (only selected tool definitions sent to model)
- Per-user customization
- Real-time tool updates without redeployment
Implementation: agent.py:67-142
Two-level caching via Strands hooks:
-
System Prompt Caching (static)
system_content = [ {"text": system_prompt}, {"cachePoint": {"type": "default"}} # Cache marker ]
-
Conversation History Caching (dynamic)
ConversationCachingHookadds cache points to last 2 messages- Removes cache points from previous messages
- Executes on
BeforeModelCallEvent
Cache Strategy:
- Max 4 cache points: system (1-2) + last 2 messages (2)
- Cache points rotate as conversation progresses
- Reduces input tokens for repeated content
Visual Explanation:
- π§ Orange: Cache creation (new content cached)
- π¦ Blue: Cache read (reusing cached content)
- Turn1 creates initial cache, Turn2+ reuses and extends cached context
Implementation: turn_based_session_manager.py:15-188
Buffers messages within a turn to reduce AgentCore Memory API calls:
Without buffering:
User message β API call 1
Assistant reply β API call 2
Tool use β API call 3
Tool result β API call 4
Total: 4 API calls per turn
With buffering:
User β Assistant β Tool β Result β Single merged API call
Total: 1 API call per turn (75% reduction)
Key Methods:
append_message(): Buffers messages instead of immediate persistence_should_flush_turn(): Detects turn completionflush(): Writes merged message to AgentCore Memory
Input Processing (agent.py:483-549):
- Converts uploaded files to
ContentBlockformat - Supports images (PNG, JPEG, GIF, WebP) and documents (PDF, CSV, DOCX, etc.)
- Files sent as raw bytes in message content array
Output Rendering:
- Tools return
ToolResultwith multimodal content - Images from AgentCore Code Interpreter and Browser rendered inline
- Image bytes delivered as raw bytes (not base64)
- Files downloadable from frontend
Example Tool Output:
return {
"content": [
{"text": "Chart generated successfully"},
{"image": {"format": "png", "source": {"bytes": image_bytes}}}
],
"status": "success"
}Implementation: agent.py:223-235
AgentCoreMemoryConfig(
memory_id=memory_id,
session_id=session_id,
actor_id=user_id,
retrieval_config={
# User preferences (coding style, language, etc.)
f"/preferences/{user_id}": RetrievalConfig(top_k=5, relevance_score=0.7),
# User-specific facts (learned information)
f"/facts/{user_id}": RetrievalConfig(top_k=10, relevance_score=0.3),
}
)Memory Tiers:
- Short-term: Session conversation history (automatic via session manager)
- Long-term: Namespaced key-value storage with vector retrieval
- Cross-session persistence via
actor_id(user identifier)
- AWS Account with Bedrock access (Claude models)
- AWS CLI configured with credentials
- Docker installed and running
- Node.js 18+ and Python 3.13+
- AgentCore enabled in your AWS account region
Run the application locally with Docker Compose:
# 1. Clone repository
git clone https://github.com/aws-samples/sample-strands-agent-with-agentcore.git
cd sample-strands-agent-with-agentcore
# 2. Setup dependencies
cd chatbot-app
./setup.sh
# 3. Configure AWS credentials
cd ../agent-blueprint
cp .env.example .env
# Edit .env with your AWS credentials and region
# 4. Start all services
cd ../chatbot-app
./start.shServices started:
- Frontend + BFF: http://localhost:3000
- Agent Backend: http://localhost:8000
- Local file-based session storage
What runs locally:
- β Frontend (Next.js)
- β AgentCore Runtime (Strands Agent)
- β Local Tools (5 tools)
- β Built-in Tools (Code Interpreter, Browser via AWS API)
- β AgentCore Gateway (requires cloud deployment)
- β AgentCore Memory (uses local file storage instead)
Deploy the full-stack application to AWS:
# Navigate to deployment directory
cd agent-blueprint
# Full deployment (all components)
./deploy.shDeployment Components:
-
Main Application Stack (
chatbot-deployment/)- Frontend + BFF (Next.js on Fargate)
- AgentCore Runtime (Strands Agent)
- AgentCore Memory (conversation persistence)
- CloudFront, ALB, Cognito
- Deploy:
cd chatbot-deployment/infrastructure && ./scripts/deploy.sh
-
AgentCore Gateway Stack (
agentcore-gateway-stack/)- MCP tool endpoints with SigV4 authentication
- 5 Lambda functions (12 tools total)
- Wikipedia, ArXiv, Google Search, Tavily, Finance
- Deploy:
cd agentcore-gateway-stack && ./scripts/deploy.sh
-
Report Writer Runtime (Optional,
agentcore-runtime-a2a-stack/)- A2A protocol-based agent collaboration
- Multi-section research report generation
- Deploy:
cd agentcore-runtime-a2a-stack/report-writer && ./deploy.sh
User β CloudFront β ALB β Frontend+BFF (Fargate)
β HTTP
AgentCore Runtime
(Strands Agent container)
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
β SigV4 β A2A β AWS SDK
AgentCore Gateway Report Writer Built-in Tools
(MCP endpoints) Runtime π§ (Code Interpreter,
β Browser + Nova Act)
Lambda Functions (5x)
ββ Wikipedia, ArXiv,
Google, Tavily, Finance
AgentCore Memory
ββ Conversation history
User preferences & facts
Frontend & Backend:
- Frontend: Next.js, React, TypeScript, Tailwind CSS, shadcn/ui
- BFF: Next.js API Routes (SSE streaming, authentication, session management)
- Deployment: AWS Fargate (containerized)
AI & Agent:
- Orchestration: Strands Agents (Python)
- Models: AWS Bedrock Claude (Haiku default, Sonnet available)
- Runtime: AgentCore Runtime (containerized Strands Agent)
AgentCore Services:
- Memory: Conversation history with user preferences/facts retrieval
- Gateway: MCP tool endpoints with SigV4 authentication
- Code Interpreter: Python code execution for diagrams/charts
- Browser: Web automation with Nova Act AI model
Tools & Integration:
- Local Tools: Direct Python function calls (5 tools)
- Built-in Tools: AWS SDK + WebSocket (4 tools)
- Gateway Tools: Lambda + MCP protocol (12 tools)
- Runtime Tools: A2A protocol (9 tools, in progress)
Infrastructure:
- IaC: AWS CDK (TypeScript)
- Frontend CDN: CloudFront
- Load Balancer: Application Load Balancer
- Authentication: AWS Cognito
- Compute: Fargate containers
Embed the chatbot in external applications:
<iframe
src="https://your-domain.com/embed"
width="100%"
height="600"
frameborder="0">
</iframe>sample-strands-agent-chatbot/
βββ chatbot-app/
β βββ frontend/ # Next.js (Frontend + BFF)
β β βββ src/
β β βββ app/api/ # API routes (BFF layer)
β β βββ components/ # React components
β β βββ config/ # Tool configuration
β βββ agentcore/ # AgentCore Runtime
β βββ src/
β βββ agent/ # ChatbotAgent + session management
β βββ local_tools/ # Weather, visualization, etc.
β βββ builtin_tools/ # Code Interpreter tools
β βββ routers/ # FastAPI routes
β
βββ agent-blueprint/
βββ chatbot-deployment/ # Main app stack (Frontend+Runtime)
βββ agentcore-gateway-stack/ # Gateway + 5 Lambda functions
βββ agentcore-runtime-stack/ # Runtime deployment (shared)
βββ agentcore-runtime-a2a-stack/ # Report Writer (optional)
- DEPLOYMENT.md: Detailed deployment instructions
- Issues: GitHub Issues
- Troubleshooting: docs/guides/TROUBLESHOOTING.md
MIT License - see LICENSE file for details.
