Strands Agents SDK
Strands Agents is a Python SDK for building and running AI agents with a model-driven approach. It simplifies the development of conversational assistants, autonomous agents, and multi-agent workflows by handling orchestration, tool invocation, and interaction with various large language models. The library is actively maintained, frequently updated, and currently at version 1.35.0.
Warnings
- breaking A critical supply chain attack impacted 'litellm' (a dependency) versions 1.82.7 and 1.82.8, which contained malicious code. Strands Agents v1.33.0 (and later) hard-pinned `litellm<=1.82.6` to mitigate this. Users on older Strands versions or with unpinned `litellm` dependencies should immediately upgrade `strands-agents` and audit their environments.
- gotcha Strands Agents defaults to using Amazon Bedrock for models. This requires AWS credentials (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`) to be configured in your environment or AWS CLI, and model access to be enabled in your AWS account. Without proper configuration, agents may fail to initialize or execute.
- gotcha The `pyaudio` dependency is optional and only included with the `bidi-io` extra. If you intend to use bidirectional streaming features requiring audio input/output, you must install `strands-agents` with this extra (e.g., `pip install strands-agents[bidi,bidi-io]`).
- gotcha When using `BedrockModel`, specifying an unsupported `service_tier` (e.g., 'flex', 'priority') for a given model or region will result in a `ValidationException`. Not all models or AWS regions support all service tiers.
- gotcha When granting agents access to tools that perform sensitive actions (e.g., SQL execution, file system operations, API calls), implement robust input validation, output sanitization, and least-privilege IAM policies. Relying solely on system prompts for security is insufficient against prompt injection or unforeseen agent behavior in production environments, potentially leading to data leakage or destructive actions.
Install
-
pip install strands-agents strands-agents-tools -
pip install strands-agents[bidi,bidi-io]
Imports
- Agent
from strands import Agent
- tool
from strands import tool
- calculator
from strands_tools import calculator
- BedrockModel
from strands.models.bedrock import BedrockModel
Quickstart
import os
from strands import Agent
from strands_tools import calculator
# Configure AWS credentials for Bedrock (if not already set via environment variables)
# For example, by setting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
# Or ensure your AWS CLI is configured with a default region and profile
agent = Agent(tools=[calculator])
async def run_agent():
print("Agent initialized. Asking a question...")
response = await agent("What is the square root of 1764?")
print(f"Agent response: {response.content}")
if __name__ == "__main__":
import asyncio
asyncio.run(run_agent())