Strands Agents Tools

0.4.1 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to load a specific tool (exa_search) from `strands_tools` and integrate it with an `Agent` from `strands_sdk`. It highlights the need to install optional dependencies for specific tools and set environment variables for authentication. Remember to install `strands-sdk` (`pip install strands-sdk`) and any optional dependencies like `strands-agents-tools[exa]`.

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}")

view raw JSON →