You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strands Agents Tools provides a powerful set of tools for your agents to use. It bridges the gap between large language models and practical applications by offering ready-to-use tools for file operations, system execution, API interactions, mathematical operations, and more.
✨ Features
📁 File Operations - Read, write, and edit files with syntax highlighting and intelligent modifications
🖥️ Shell Integration - Execute and interact with shell commands securely
🧠 Memory - Store user and agent memories across agent runs to provide personalized experiences with both Mem0 and Amazon Bedrock Knowledge Bases
🌐 HTTP Client - Make API requests with comprehensive authentication support
💬 Slack Client - Real-time Slack events, message processing, and Slack API access
🐍 Python Execution - Run Python code snippets with state persistence, user confirmation for code execution, and safety features
🧮 Mathematical Tools - Perform advanced calculations with symbolic math capabilities
☁️ AWS Integration - Seamless access to AWS services
🖼️ Image Processing - Generate and process images for AI applications
🎥 Video Processing - Use models and agents to generate dynamic videos
🎙️ Audio Output - Enable models to generate audio and speak
fromstrandsimportAgentfromstrands_toolsimportshellagent=Agent(tools=[shell])
# Execute a single commandresult=agent.tool.shell(command="ls -la")
# Execute a sequence of commandsresults=agent.tool.shell(command=["mkdir -p test_dir", "cd test_dir", "touch test.txt"])
# Execute commands with error handlingagent.tool.shell(command="risky-command", ignore_errors=True)
HTTP Requests
fromstrandsimportAgentfromstrands_toolsimporthttp_requestagent=Agent(tools=[http_request])
# Make a simple GET requestresponse=agent.tool.http_request(
method="GET",
url="https://api.example.com/data"
)
# POST request with authenticationresponse=agent.tool.http_request(
method="POST",
url="https://api.example.com/resource",
headers={"Content-Type": "application/json"},
body=json.dumps({"key": "value"}),
auth_type="Bearer",
auth_token="your_token_here"
)
Python Code Execution
fromstrandsimportAgentfromstrands_toolsimportpython_replagent=Agent(tools=[python_repl])
# Execute Python code with state persistenceresult=agent.tool.python_repl(code="""import pandas as pd# Load and process datadata = pd.read_csv('data.csv')processed = data.groupby('category').mean()processed.head()""")
Swarm Intelligence
fromstrandsimportAgentfromstrands_toolsimportswarmagent=Agent(tools=[swarm])
# Create a collaborative swarm of agents to tackle a complex problemresult=agent.tool.swarm(
task="Generate creative solutions for reducing plastic waste in urban areas",
swarm_size=5,
coordination_pattern="collaborative"
)
# Create a competitive swarm for diverse solution generationresult=agent.tool.swarm(
task="Design an innovative product for smart home automation",
swarm_size=3,
coordination_pattern="competitive"
)
# Hybrid approach combining collaboration and competitionresult=agent.tool.swarm(
task="Develop marketing strategies for a new sustainable fashion brand",
swarm_size=4,
coordination_pattern="hybrid"
)
Use AWS
fromstrandsimportAgentfromstrands_toolsimportuse_awsagent=Agent(tools=[use_aws])
# List S3 bucketsresult=agent.tool.use_aws(
service_name="s3",
operation_name="list_buckets",
parameters={},
region="us-east-1",
label="List all S3 buckets"
)
# Get the contents of a specific S3 bucketresult=agent.tool.use_aws(
service_name="s3",
operation_name="list_objects_v2",
parameters={"Bucket": "example-bucket"}, # Replace with your actual bucket nameregion="us-east-1",
label="List objects in a specific S3 bucket"
)
# Get the list of EC2 subnetsresult=agent.tool.use_aws(
service_name="ec2",
operation_name="describe_subnets",
parameters={},
region="us-east-1",
label="List all subnets"
)
🌍 Environment Variables Configuration
Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production).
Global Environment Variables
These variables affect multiple tools:
Environment Variable
Description
Default
Affected Tools
BYPASS_TOOL_CONSENT
Bypass consent for tool invocation, set to "true" to enable
false
All tools that require consent (e.g. shell, file_write, python_repl)
STRANDS_TOOL_CONSOLE_MODE
Enable rich UI for tools, set to "enabled" to enable