What is ReAct?
ReAct is an agent framework that combines reasoning and actions:- Thought: Agent analyzes the current situation
- Action: Agent decides on and executes a tool
- Observation: Agent reviews the tool’s output
- Repeat: Continue until the task is complete
- Handle multi-step tasks
- Recover from errors
- Adapt to dynamic situations
- Provide transparent reasoning
Bedrock Chat implements agents using Strands Agents, an open-source SDK with a model-driven approach supporting multiple providers including Amazon Bedrock.
Built-in Tools
Bedrock Chat includes several pre-built tools:Internet Search
Search the web using DuckDuckGo or Firecrawl. Returns summarized results with citations.
Knowledge Search
Query the bot’s knowledge base for relevant information from uploaded documents.
Calculator
Perform mathematical calculations safely. Supports basic and advanced operations.
Excel Editor
Read and manipulate Excel files. Useful for data analysis tasks.
Simple List
Manage lists and structured data. Create, update, and query list items.
Bedrock Agent
Integrate with existing Amazon Bedrock Agents for complex workflows.
Enabling Agent Functionality
To enable agents for a custom bot:- Create or edit a bot
- Navigate to the Agent section
- Toggle on desired tools
- Configure tool-specific settings (if needed)
- Save changes
Tool Configuration
Internet Search
Configure search behavior:Search Engine Comparison
Search Engine Comparison
DuckDuckGo:
- Free, no API key required
- Good general web search
- Basic content extraction
- Time-based filtering (day, week, month, year)
- Requires API key (stored in AWS Secrets Manager)
- Advanced content parsing
- Better structured data extraction
- Configurable result count
- Fallback to DuckDuckGo if no results
- Summarizes search results using Claude Haiku
- Includes source citations
- Returns structured data for the agent
Bedrock Agent Integration
Connect to an existing Bedrock Agent:- Complex business workflows
- Integration with enterprise systems
- Multi-step approval processes
- Custom tool suites
Plain Tools
Simple tools without additional configuration:Agent Execution Flow
When a user sends a message to an agent-enabled bot:Example: Multi-Step Task
User: “What’s the weather in Paris and convert 20°C to Fahrenheit?”- Thought: I need to search for Paris weather and do a calculation
- Action: Use internet_search for Paris weather
- Observation: Current temperature is 20°C
- Thought: Now convert 20°C to Fahrenheit
- Action: Use calculator: (20 * 9/5) + 32
- Observation: Result is 68°F
- Final Response: “The weather in Paris is currently 20°C (68°F)…”
Creating Custom Tools
Develop your own tools using the Strands SDK:Basic Tool Structure
Tool Development Guidelines
Clear Docstrings
The LLM uses your docstring to decide when to use the tool. Be specific and clear.
Type Hints
Use proper type hints. Strands automatically generates tool specs from them.
Error Handling
Always handle errors gracefully and return informative error messages.
Bot Context
Use closure pattern to access bot configuration if needed.
Return Format
All tools must return a dictionary with:- Use
{"text": "..."}for simple messages - Use
{"json": data}for complex structured data
Example: BMI Calculator
Registering Custom Tools
- Place your tool in
backend/app/strands_integration/tools/ - Edit
backend/app/strands_integration/utils.py:
- (Optional) Add UI labels in
frontend/src/i18n/en/index.ts:
- Deploy:
npx cdk deploy
The UI labels are optional. If not provided, the tool name and description from your function will be used.
Agent Best Practices
Tool Selection
Enable only tools the bot needs. Too many tools can confuse the agent and slow execution.
Clear Instructions
Provide clear bot instructions about when and how to use tools.
Error Messages
Return informative error messages to help the agent recover and try alternative approaches.
Structured Data
Use JSON return format for complex data the agent needs to process further.
Real-World Use Cases
Text-to-SQL Agent
Text-to-SQL Agent
Tools: Database query tool, schema inspectorFlow:
- User asks: “What were total sales last quarter?”
- Agent inspects database schema
- Agent generates SQL query
- Agent executes query
- Agent formats results for user
Research Assistant
Research Assistant
Tools: Internet search, knowledge search, calculatorFlow:
- User asks: “Compare market share of top 3 cloud providers”
- Agent searches web for recent data
- Agent searches internal knowledge base
- Agent calculates percentages
- Agent compiles comprehensive report
Data Analysis Bot
Data Analysis Bot
Tools: Excel editor, calculator, internet searchFlow:
- User uploads sales data Excel file
- Agent reads and analyzes data
- Agent calculates trends and metrics
- Agent searches for industry benchmarks
- Agent provides insights with context
Monitoring Agent Execution
During agent execution, users see:- Thinking indicator: Agent is reasoning
- Tool usage: Which tool is being used
- Tool results: Output from tools (if configured)
- Progress updates: Multi-step task progress
- Tool usage statistics
- Success/failure rates
- Average execution time
- Token consumption per tool
Troubleshooting
Agent Not Using Tools
Agent Not Using Tools
Check:
- Tools are enabled in bot configuration
- Bot instructions mention tool availability
- Task actually requires tool usage
- Tool descriptions are clear and relevant
Tool Execution Errors
Tool Execution Errors
- Review tool error messages
- Check tool implementation for bugs
- Verify required credentials (e.g., Firecrawl API key)
- Ensure bot has necessary permissions
Slow Agent Responses
Slow Agent Responses
- Reduce number of enabled tools
- Optimize tool execution time
- Use faster models (Haiku) for agent reasoning
- Limit tool result size
Advanced Topics
Combining Agents with Knowledge
Agents can search both:- External knowledge (internet)
- Internal knowledge (bot’s knowledge base)
Tool Chaining
Agents automatically chain tools: Example: “Find recent AI news and summarize in bullet points”- internet_search → Get recent articles
- (Agent reasoning) → Extract key points
- (Response generation) → Format as bullets
Next Steps
Custom Bots
Create bots with agent capabilities
Knowledge Bases
Combine agents with RAG for powerful bots
Bot Store
Share agent-powered bots with others
API Publishing
Create APIs with agent capabilities