Strands Agents Tools
Strands Agents Tools is a collection of specialized tools designed for use with Strands Agents. It provides functionalities like web search, code interpretation, and data interaction for Large Language Models. The library maintains a frequent release cadence, often with minor version updates addressing bug fixes, security enhancements, and new tool capabilities. The current version is 0.4.1.
Warnings
- breaking In version 0.4.0, the `exa_search` tool's API changed significantly. The `neural` and `keyword` search types were removed, and the `deep` search mode was introduced as the primary comprehensive search option.
- gotcha Many tools within `strands-agents-tools` (e.g., `exa_search`, `selenium_browser`, `mongodb_atlas`) require additional optional dependencies to be installed. The core `strands-agents-tools` package does not include these by default.
- gotcha Most tools require corresponding API keys or credentials to be set as environment variables (e.g., `EXA_API_KEY`, `ANTHROPIC_API_KEY`). Without these, tools will fail to initialize or execute.
- gotcha While the tools are imported from `strands_tools`, the `Agent` class itself, commonly used to orchestrate these tools, is typically provided by the `strands_sdk` library, which needs to be installed separately.
- gotcha Version 0.4.1 introduced namespace validation and fixes for Time-of-Check to Time-of-Use (TOCTOU) vulnerabilities in Elasticsearch and MongoDB memory tools. Older versions might be susceptible to security risks if not properly configured.
Install
-
pip install strands-agents-tools
Imports
- load_tools
from strands_tools import load_tools
- exa_search
from strands_tools import exa_search
Quickstart
import os
from strands_sdk import Agent # Note: strands-sdk is often used in conjunction with strands-agents-tools
from strands_tools import load_tools
# To use tools like exa_search, install its optional dependency:
# pip install strands-agents-tools[exa]
# and set the corresponding API key as an environment variable.
# Example: os.environ['EXA_API_KEY'] = 'your-exa-api-key'
os.environ['EXA_API_KEY'] = os.environ.get('EXA_API_KEY', 'YOUR_EXA_API_KEY_HERE')
try:
# Load specific tools by name
# bypass_tool_consent=True is often useful for quickstarts
tools = load_tools(tool_names=["exa_search"], bypass_tool_consent=True)
# Initialize the agent with the loaded tools
# The Agent class typically comes from strands_sdk, install with: pip install strands-sdk
agent = Agent(tools=tools)
# Use the agent with a query
response = agent("Perform a deep search on recent developments in quantum computing.")
print(f"Agent Response: {response}")
except ImportError as e:
print(f"Could not load tools or agent: {e}. Ensure all necessary optional dependencies (e.g., '[exa]') and 'strands-sdk' are installed.")
except Exception as e:
print(f"An error occurred during agent execution: {e}")