Skip to main content
Agents transform your bots from conversational assistants into autonomous problem-solvers. Using the ReAct (Reasoning + Acting) framework, agents can break down complex tasks, use tools, and iteratively work toward solutions.

What is ReAct?

ReAct is an agent framework that combines reasoning and actions:
  1. Thought: Agent analyzes the current situation
  2. Action: Agent decides on and executes a tool
  3. Observation: Agent reviews the tool’s output
  4. Repeat: Continue until the task is complete
This iterative process allows agents to:
  • 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:
  1. Create or edit a bot
  2. Navigate to the Agent section
  3. Toggle on desired tools
  4. Configure tool-specific settings (if needed)
  5. Save changes
The bot now has access to selected tools during conversations.

Tool Configuration

Configure search behavior:
{
  "tool_type": "internet",
  "name": "internet_search",
  "description": "Search the internet for information",
  "search_engine": "duckduckgo",  # or "firecrawl"
  "firecrawl_config": {
    "api_key": "<encrypted>",
    "max_results": 10
  }
}
DuckDuckGo:
  • Free, no API key required
  • Good general web search
  • Basic content extraction
  • Time-based filtering (day, week, month, year)
Firecrawl:
  • Requires API key (stored in AWS Secrets Manager)
  • Advanced content parsing
  • Better structured data extraction
  • Configurable result count
  • Fallback to DuckDuckGo if no results
The tool automatically:
  • Summarizes search results using Claude Haiku
  • Includes source citations
  • Returns structured data for the agent

Bedrock Agent Integration

Connect to an existing Bedrock Agent:
{
  "tool_type": "bedrock_agent",
  "name": "my_bedrock_agent",
  "description": "Custom business workflow agent",
  "bedrockAgentConfig": {
    "agent_id": "AGENT123",
    "alias_id": "TSTALIASID"
  }
}
Use cases:
  • Complex business workflows
  • Integration with enterprise systems
  • Multi-step approval processes
  • Custom tool suites

Plain Tools

Simple tools without additional configuration:
{
  "tool_type": "plain",
  "name": "calculator",
  "description": "Perform mathematical calculations"
}

Agent Execution Flow

When a user sends a message to an agent-enabled bot:
User Query → Agent Reasoning → Tool Selection → Tool Execution
                  ↓                                    ↓
              Thought                             Observation
                  ↓                                    ↓
              Is task complete? ←─────────────────────┘

               Yes: Final Response
               No: Continue loop

Example: Multi-Step Task

User: “What’s the weather in Paris and convert 20°C to Fahrenheit?”
  1. Thought: I need to search for Paris weather and do a calculation
  2. Action: Use internet_search for Paris weather
  3. Observation: Current temperature is 20°C
  4. Thought: Now convert 20°C to Fahrenheit
  5. Action: Use calculator: (20 * 9/5) + 32
  6. Observation: Result is 68°F
  7. 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

from strands import tool
from app.repositories.models.custom_bot import BotModel

def create_my_tool(bot: BotModel | None = None):
    """Create custom tool with bot context closure."""
    
    @tool
    def my_custom_tool(param1: str, param2: int) -> dict:
        """
        Brief description of what this tool does.
        
        Args:
            param1: Description of first parameter
            param2: Description of second parameter
            
        Returns:
            dict: Result in Strands format
        """
        try:
            # Your tool logic here
            result = do_something(param1, param2)
            
            return {
                "toolUseId": "placeholder",
                "status": "success",
                "content": [{"json": result}]  # or {"text": "..."}
            }
        except Exception as e:
            return {
                "toolUseId": "placeholder",
                "status": "error",
                "content": [{"text": f"Error: {str(e)}"}]
            }
    
    return my_custom_tool

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:
{
    "toolUseId": "placeholder",  # Replaced by Strands
    "status": "success" | "error",
    "content": [
        {"text": "Simple message"}  # For text responses
        # OR
        {"json": {"key": "value"}}  # For structured data
    ]
}
  • Use {"text": "..."} for simple messages
  • Use {"json": data} for complex structured data

Example: BMI Calculator

from strands import tool
from app.repositories.models.custom_bot import BotModel

def create_bmi_tool(bot: BotModel | None = None):
    """Create BMI calculation tool with bot context closure."""
    
    @tool
    def calculate_bmi(height: float, weight: float) -> dict:
        """
        Calculate the Body Mass Index (BMI) from height and weight.
        
        Args:
            height: Height in centimeters (cm). e.g. 170.0
            weight: Weight in kilograms (kg). e.g. 70.0
            
        Returns:
            dict: BMI calculation result in Strands format
        """
        try:
            if height <= 0 or weight <= 0:
                return {
                    "toolUseId": "placeholder",
                    "status": "error",
                    "content": [{"text": "Height and weight must be positive"}]
                }
            
            height_m = height / 100
            bmi = weight / (height_m ** 2)
            
            category = (
                "Underweight" if bmi < 18.5 else
                "Normal" if bmi < 25 else
                "Overweight" if bmi < 30 else
                "Obese"
            )
            
            return {
                "toolUseId": "placeholder",
                "status": "success",
                "content": [{
                    "json": {
                        "bmi": round(bmi, 1),
                        "category": category,
                        "height_cm": height,
                        "weight_kg": weight
                    }
                }]
            }
        except Exception as e:
            return {
                "toolUseId": "placeholder",
                "status": "error",
                "content": [{"text": f"BMI calculation error: {str(e)}"}]
            }
    
    return calculate_bmi

Registering Custom Tools

  1. Place your tool in backend/app/strands_integration/tools/
  2. Edit backend/app/strands_integration/utils.py:
def get_strands_registered_tools(bot: BotModel | None) -> list:
    """Get all registered Strands tools."""
    from .tools.my_tool import create_my_tool
    
    return [
        create_internet_search_tool(bot),
        create_calculator_tool(bot),
        create_my_tool(bot),  # Add your tool
        # ... other tools
    ]
  1. (Optional) Add UI labels in frontend/src/i18n/en/index.ts:
agent: {
  tools: {
    my_custom_tool: {
      name: "My Custom Tool",
      description: "User-friendly description for the UI"
    }
  }
}
  1. 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

Tools: Database query tool, schema inspectorFlow:
  1. User asks: “What were total sales last quarter?”
  2. Agent inspects database schema
  3. Agent generates SQL query
  4. Agent executes query
  5. Agent formats results for user
Tools: Internet search, knowledge search, calculatorFlow:
  1. User asks: “Compare market share of top 3 cloud providers”
  2. Agent searches web for recent data
  3. Agent searches internal knowledge base
  4. Agent calculates percentages
  5. Agent compiles comprehensive report
Tools: Excel editor, calculator, internet searchFlow:
  1. User uploads sales data Excel file
  2. Agent reads and analyzes data
  3. Agent calculates trends and metrics
  4. Agent searches for industry benchmarks
  5. 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
Administrators can view:
  • Tool usage statistics
  • Success/failure rates
  • Average execution time
  • Token consumption per tool

Troubleshooting

Check:
  • Tools are enabled in bot configuration
  • Bot instructions mention tool availability
  • Task actually requires tool usage
  • Tool descriptions are clear and relevant
  • Review tool error messages
  • Check tool implementation for bugs
  • Verify required credentials (e.g., Firecrawl API key)
  • Ensure bot has necessary permissions
  • 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)
This enables powerful hybrid retrieval:
{
  "agent": {
    "tools": [
      {"tool_type": "internet", "name": "internet_search"},
      {"tool_type": "plain", "name": "knowledge_search"}
    ]
  },
  "knowledge": {
    "filenames": ["internal_docs.pdf"]
  }
}

Tool Chaining

Agents automatically chain tools: Example: “Find recent AI news and summarize in bullet points”
  1. internet_search → Get recent articles
  2. (Agent reasoning) → Extract key points
  3. (Response generation) → Format as bullets
No explicit chaining required—the agent figures it out.

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

Build docs developers (and LLMs) love