Overview
Bedrock Chat implements agents using the ReAct (Reasoning + Acting) approach, powered by Strands Agents, an open-source SDK for building AI agents. You can develop custom tools to extend the capabilities of your agents using Python decorators and the Strands framework.About Strands Tools
Strands provides a simple@tool decorator that transforms regular Python functions into AI agent tools. The decorator automatically extracts information from your function’s docstring and type hints to create tool specifications that the LLM can understand and use.
For detailed information, see the Python Tools documentation.
Basic Tool Creation
Create a function decorated with@tool from Strands:
Tools with Bot Context (Closure Pattern)
To access bot information (BotModel), use a closure pattern that captures the bot context:Complete Example: BMI Calculator
Here’s a complete example demonstrating best practices:Return Format Requirements
All Strands tools must return a dictionary with this structure:- Use
{"text": "message"}for simple text responses - Use
{"json": data}for complex data that should be preserved as structured information - Always set
statusto either"success"or"error"
Implementation Guidelines
Documentation
The function name and docstring are used when the LLM considers which tool to use. The docstring is embedded in the prompt, so describe the tool’s purpose and parameters precisely.File Location
Place your implementation file in thebackend/app/strands_integration/tools/ directory.
Registration
Openbackend/app/strands_integration/utils.py and edit get_strands_registered_tools to include your new tool.
Frontend Labels (Optional)
Add clear names and descriptions for the frontend UI. While optional, this improves UX by providing user-friendly explanations instead of using the technical function names.- Edit
frontend/src/i18n/en/index.tsand add yournameanddescriptionunderagent.tools - Edit other language files (e.g.,
ja/index.ts) as needed
Deployment
Runnpx cdk deploy to deploy your changes and make your custom tool available in the custom bot screen.