Skip to content

Repository files navigation

Strands Agents

Strands Agents

A model-driven approach to building AI agents in just a few lines of code.

GitHub commit activityGitHub open issuesGitHub open pull requestsLicensePyPI versionPython versions

DocumentationSamplesPython SDKToolsAgent BuilderMCP Server

Strands Agents is a simple yet powerful SDK that takes a model-driven approach to building and running AI agents. From simple conversational assistants to complex autonomous workflows, from local development to production deployment, Strands Agents scales with your needs.

Feature Overview

  • Lightweight & Flexible: Simple agent loop that just works and is fully customizable
  • Model Agnostic: Support for Amazon Bedrock, Anthropic, Gemini, LiteLLM, Llama, Ollama, OpenAI, Writer, and custom providers
  • Advanced Capabilities: Multi-agent systems, autonomous agents, and streaming support
  • Built-in MCP: Native support for Model Context Protocol (MCP) servers, enabling access to thousands of pre-built tools

Quick Start

# Install Strands Agents
pip install strands-agents strands-agents-tools
fromstrandsimportAgentfromstrands_toolsimportcalculatoragent=Agent(tools=[calculator])
agent("What is the square root of 1764")

Note: For the default Amazon Bedrock model provider, you'll need AWS credentials configured and model access enabled for Claude 4 Sonnet in the us-west-2 region. See the Quickstart Guide for details on configuring other model providers.

Installation

Ensure you have Python 3.10+ installed, then:

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate# Install Strands and tools
pip install strands-agents strands-agents-tools

Features at a Glance

Python-Based Tools

Easily build tools using Python decorators:

fromstrandsimportAgent, tool@tooldefword_count(text: str) ->int:
"""Count words in text. This docstring is used by the LLM to understand the tool's purpose. """returnlen(text.split())
agent=Agent(tools=[word_count])
response=agent("How many words are in this sentence?")

Hot Reloading from Directory: Enable automatic tool loading and reloading from the ./tools/ directory:

fromstrandsimportAgent# Agent will watch ./tools/ directory for changesagent=Agent(load_tools_from_directory=True)
response=agent("Use any tools you find in the tools directory")

MCP Support

Seamlessly integrate Model Context Protocol (MCP) servers:

fromstrandsimportAgentfromstrands.tools.mcpimportMCPClientfrommcpimportstdio_client, StdioServerParametersaws_docs_client=MCPClient(
lambda: stdio_client(StdioServerParameters(command="uvx", args=["awslabs.aws-documentation-mcp-server@latest"]))
)
withaws_docs_client:
agent=Agent(tools=aws_docs_client.list_tools_sync())
response=agent("Tell me about Amazon Bedrock and how to use it with Python")

Multiple Model Providers

Support for various model providers:

fromstrandsimportAgentfromstrands.modelsimportBedrockModelfromstrands.models.ollamaimportOllamaModelfromstrands.models.llamaapiimportLlamaAPIModelfromstrands.models.geminiimportGeminiModelfromstrands.models.llamacppimportLlamaCppModel# Bedrockbedrock_model=BedrockModel(
model_id="us.amazon.nova-pro-v1:0",
temperature=0.3,
streaming=True, # Enable/disable streaming
)
agent=Agent(model=bedrock_model)
agent("Tell me about Agentic AI")
# Google Geminigemini_model=GeminiModel(
client_args={
"api_key": "your_gemini_api_key",
},
model_id="gemini-2.5-flash",
params={"temperature": 0.7}
)
agent=Agent(model=gemini_model)
agent("Tell me about Agentic AI")
# Ollamaollama_model=OllamaModel(
host="http://localhost:11434",
model_id="llama3"
)
agent=Agent(model=ollama_model)
agent("Tell me about Agentic AI")
# Llama APIllama_model=LlamaAPIModel(
model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
)
agent=Agent(model=llama_model)
response=agent("Tell me about Agentic AI")

Built-in providers:

Custom providers can be implemented using Custom Providers

Example tools

Strands offers an optional strands-agents-tools package with pre-built tools for quick experimentation:

fromstrandsimportAgentfromstrands_toolsimportcalculatoragent=Agent(tools=[calculator])
agent("What is the square root of 1764")

It's also available on GitHub via strands-agents/tools.

Bidirectional Streaming

⚠️ Experimental Feature: Bidirectional streaming is currently in experimental status. APIs may change in future releases as we refine the feature based on user feedback and evolving model capabilities.

Build real-time voice and audio conversations with persistent streaming connections. Unlike traditional request-response patterns, bidirectional streaming maintains long-running conversations where users can interrupt, provide continuous input, and receive real-time audio responses. Get started with your first BidiAgent by following the Quickstart guide.

Supported Model Providers:

  • Amazon Nova Sonic (v1, v2)
  • Google Gemini Live
  • OpenAI Realtime API

Installation:

# Server-side only (no audio I/O dependencies)
pip install strands-agents[bidi]
# With audio I/O support (includes PyAudio dependency)
pip install strands-agents[bidi,bidi-io]

Quick Example:

importasynciofromstrands.experimental.bidiimportBidiAgentfromstrands.experimental.bidi.modelsimportBidiNovaSonicModelfromstrands.experimental.bidi.ioimportBidiAudioIO, BidiTextIOfromstrands.experimental.bidi.toolsimportstop_conversationfromstrands_toolsimportcalculatorasyncdefmain():
# Create bidirectional agent with Nova Sonic v2model=BidiNovaSonicModel()
agent=BidiAgent(model=model, tools=[calculator, stop_conversation])
# Setup audio and text I/O (requires bidi-io extra)audio_io=BidiAudioIO()
text_io=BidiTextIO()
# Run with real-time audio streaming# Say "stop conversation" to gracefully end the conversationawaitagent.run(
inputs=[audio_io.input()],
outputs=[audio_io.output(), text_io.output()]
)
if__name__=="__main__":
asyncio.run(main())

Note: BidiAudioIO and BidiTextIO require the bidi-io extra. For server-side deployments where audio I/O is handled by clients (browsers, mobile apps), install only strands-agents[bidi] and implement custom input/output handlers using the BidiInput and BidiOutput protocols.

Configuration Options:

fromstrands.experimental.bidi.modelsimportBidiNovaSonicModel# Configure audio settings and turn detection (v2 only)model=BidiNovaSonicModel(
provider_config={
"audio": {
"input_rate": 16000,
"output_rate": 16000,
"voice": "matthew"
},
"turn_detection": {
"endpointingSensitivity": "MEDIUM"# HIGH, MEDIUM, or LOW
},
"inference": {
"max_tokens": 2048,
"temperature": 0.7
}
}
)
# Configure I/O devicesaudio_io=BidiAudioIO(
input_device_index=0, # Specific microphoneoutput_device_index=1, # Specific speakerinput_buffer_size=10,
output_buffer_size=10
)
# Text input mode (type messages instead of speaking)text_io=BidiTextIO()
awaitagent.run(
inputs=[text_io.input()], # Use text inputoutputs=[audio_io.output(), text_io.output()]
)
# Multi-modal: Both audio and text inputawaitagent.run(
inputs=[audio_io.input(), text_io.input()], # Speak OR typeoutputs=[audio_io.output(), text_io.output()]
)

Documentation

For detailed guidance & examples, explore our documentation:

Contributing ❤️

We welcome contributions! See our Contributing Guide for details on:

  • Reporting bugs & features
  • Development setup
  • Contributing via Pull Requests
  • Code of Conduct
  • Reporting of security issues

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Security

See CONTRIBUTING for more information.

About

A model-driven approach to building AI agents in just a few lines of code.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages