https://github.com/strands-agents/sdk-python
A model-driven approach to building AI agents in just a few lines of code.
https://github.com/strands-agents/sdk-python
agentic agentic-ai agents ai anthropic autonomous-agents bedrock genai litellm llama llm machine-learning mcp multi-agent-systems ollama openai opentelemetry python strands-agents
Last synced: 9 days ago
JSON representation
A model-driven approach to building AI agents in just a few lines of code.
- Host: GitHub
- URL: https://github.com/strands-agents/sdk-python
- Owner: strands-agents
- License: apache-2.0
- Created: 2025-05-14T19:59:51.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-01-16T18:48:51.000Z (14 days ago)
- Last Synced: 2026-01-17T04:43:27.542Z (13 days ago)
- Topics: agentic, agentic-ai, agents, ai, anthropic, autonomous-agents, bedrock, genai, litellm, llama, llm, machine-learning, mcp, multi-agent-systems, ollama, openai, opentelemetry, python, strands-agents
- Language: Python
- Homepage: https://strandsagents.com
- Size: 2.54 MB
- Stars: 4,891
- Watchers: 49
- Forks: 601
- Open Issues: 338
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
- Notice: NOTICE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-ai-agents - Strands Agents SDK - agents/sdk-python) |AWS-backed model-driven agent SDK with MCP and multi-provider support | (🌟 Core Frameworks)
- awesome-ChatGPT-repositories - sdk-python - A model-driven approach to building AI agents in just a few lines of code. (Langchain)
- awesome-agents - Strands Agents SDK - driven approach to building AI agents in just a few lines of code.  (Frameworks)
- awesome-repositories - strands-agents/sdk-python - A model-driven approach to building AI agents in just a few lines of code. (Python)
- awesome_ai_agents - Strands Agents SDK - A model-driven approach to building AI agents in just a few lines of code. [github](https://github.com/strands-agents/sdk-python) (Building / Frameworks)
- awesome-strands-agents - Python SDK - Core SDK (Official Resources / For PyPI Packages)
- StarryDivineSky - strands-agents/sdk-python - agents/sdk-python 是一个基于模型驱动方法构建 AI 代理(AI Agents)的 Python 开发工具包,其核心目标是通过极简的代码实现复杂代理系统的开发。项目采用模块化设计,开发者只需编写少量代码即可定义代理的行为逻辑、状态转换和决策机制,底层框架会自动处理代理与环境的交互、状态管理等复杂流程。该工具包特别强调“模型驱动”特性,即通过抽象的模型描述(如状态机、行为树或规则引擎)来替代传统的硬编码逻辑,使代理系统更易扩展和维护。其工作原理基于分层架构:上层允许用户用 Python 脚本快速定义代理模型,中层通过预置的算法引擎解析模型并生成可执行代码,底层则提供与外部环境(如模拟器、传感器)对接的接口。项目特色包括支持多代理协作、动态行为调整以及可视化调试工具,适合用于机器人控制、自动化任务调度、智能客服等场景。由于代码简洁且功能聚焦,它降低了 AI 代理开发的技术门槛,同时保持了高度灵活性,开发者可自定义模型规则或扩展框架功能。目前该项目尚未提供完整文档和示例代码,但其核心理念已体现出对 AI 代理开发流程的深度优化。 (A01_文本生成_文本对话 / 大语言对话模型及数据)
- awesome-mcp - strands-agents/sdk-python - Strands Agents is a Python SDK that enables building and running AI agents using a model-driven approach with native support for Model Context Protocol (MCP) servers and multiple AI model providers. (MCP Frameworks and libraries / Python)
- awesome-ai-agents - strands-agents/sdk-python - Strands Agents is a Python SDK that enables building and deploying AI agents using a model-driven approach, supporting multiple AI models and advanced features like multi-agent systems and MCP integration. (Agent Integration & Deployment Tools / AI Agent Orchestration)
README
Strands Agents
A model-driven approach to building AI agents in just a few lines of code.
Documentation
◆ Samples
◆ Python SDK
◆ Tools
◆ Agent Builder
◆ MCP 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
```bash
# Install Strands Agents
pip install strands-agents strands-agents-tools
```
```python
from strands import Agent
from strands_tools import calculator
agent = 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](https://strandsagents.com/) for details on configuring other model providers.
## Installation
Ensure you have Python 3.10+ installed, then:
```bash
# 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:
```python
from strands import Agent, tool
@tool
def word_count(text: str) -> int:
"""Count words in text.
This docstring is used by the LLM to understand the tool's purpose.
"""
return len(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:
```python
from strands import Agent
# Agent will watch ./tools/ directory for changes
agent = 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:
```python
from strands import Agent
from strands.tools.mcp import MCPClient
from mcp import stdio_client, StdioServerParameters
aws_docs_client = MCPClient(
lambda: stdio_client(StdioServerParameters(command="uvx", args=["awslabs.aws-documentation-mcp-server@latest"]))
)
with aws_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:
```python
from strands import Agent
from strands.models import BedrockModel
from strands.models.ollama import OllamaModel
from strands.models.llamaapi import LlamaAPIModel
from strands.models.gemini import GeminiModel
from strands.models.llamacpp import LlamaCppModel
# Bedrock
bedrock_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 Gemini
gemini_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")
# Ollama
ollama_model = OllamaModel(
host="http://localhost:11434",
model_id="llama3"
)
agent = Agent(model=ollama_model)
agent("Tell me about Agentic AI")
# Llama API
llama_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:
- [Amazon Bedrock](https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/)
- [Anthropic](https://strandsagents.com/latest/user-guide/concepts/model-providers/anthropic/)
- [Gemini](https://strandsagents.com/latest/user-guide/concepts/model-providers/gemini/)
- [Cohere](https://strandsagents.com/latest/user-guide/concepts/model-providers/cohere/)
- [LiteLLM](https://strandsagents.com/latest/user-guide/concepts/model-providers/litellm/)
- [llama.cpp](https://strandsagents.com/latest/user-guide/concepts/model-providers/llamacpp/)
- [LlamaAPI](https://strandsagents.com/latest/user-guide/concepts/model-providers/llamaapi/)
- [MistralAI](https://strandsagents.com/latest/user-guide/concepts/model-providers/mistral/)
- [Ollama](https://strandsagents.com/latest/user-guide/concepts/model-providers/ollama/)
- [OpenAI](https://strandsagents.com/latest/user-guide/concepts/model-providers/openai/)
- [SageMaker](https://strandsagents.com/latest/user-guide/concepts/model-providers/sagemaker/)
- [Writer](https://strandsagents.com/latest/user-guide/concepts/model-providers/writer/)
Custom providers can be implemented using [Custom Providers](https://strandsagents.com/latest/user-guide/concepts/model-providers/custom_model_provider/)
### Example tools
Strands offers an optional strands-agents-tools package with pre-built tools for quick experimentation:
```python
from strands import Agent
from strands_tools import calculator
agent = Agent(tools=[calculator])
agent("What is the square root of 1764")
```
It's also available on GitHub via [strands-agents/tools](https://github.com/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](https://strandsagents.com/latest/documentation/docs/user-guide/concepts/experimental/bidirectional-streaming/quickstart) guide.
**Supported Model Providers:**
- Amazon Nova Sonic (v1, v2)
- Google Gemini Live
- OpenAI Realtime API
**Quick Example:**
```python
import asyncio
from strands.experimental.bidi import BidiAgent
from strands.experimental.bidi.models import BidiNovaSonicModel
from strands.experimental.bidi.io import BidiAudioIO, BidiTextIO
from strands.experimental.bidi.tools import stop_conversation
from strands_tools import calculator
async def main():
# Create bidirectional agent with Nova Sonic v2
model = BidiNovaSonicModel()
agent = BidiAgent(model=model, tools=[calculator, stop_conversation])
# Setup audio and text I/O
audio_io = BidiAudioIO()
text_io = BidiTextIO()
# Run with real-time audio streaming
# Say "stop conversation" to gracefully end the conversation
await agent.run(
inputs=[audio_io.input()],
outputs=[audio_io.output(), text_io.output()]
)
if __name__ == "__main__":
asyncio.run(main())
```
**Configuration Options:**
```python
from strands.experimental.bidi.models import BidiNovaSonicModel
# 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 devices
audio_io = BidiAudioIO(
input_device_index=0, # Specific microphone
output_device_index=1, # Specific speaker
input_buffer_size=10,
output_buffer_size=10
)
# Text input mode (type messages instead of speaking)
text_io = BidiTextIO()
await agent.run(
inputs=[text_io.input()], # Use text input
outputs=[audio_io.output(), text_io.output()]
)
# Multi-modal: Both audio and text input
await agent.run(
inputs=[audio_io.input(), text_io.input()], # Speak OR type
outputs=[audio_io.output(), text_io.output()]
)
```
## Documentation
For detailed guidance & examples, explore our documentation:
- [User Guide](https://strandsagents.com/)
- [Quick Start Guide](https://strandsagents.com/latest/user-guide/quickstart/)
- [Agent Loop](https://strandsagents.com/latest/user-guide/concepts/agents/agent-loop/)
- [Examples](https://strandsagents.com/latest/examples/)
- [API Reference](https://strandsagents.com/latest/api-reference/agent/)
- [Production & Deployment Guide](https://strandsagents.com/latest/user-guide/deploy/operating-agents-in-production/)
## Contributing ❤️
We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) 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](LICENSE) file for details.
## Security
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.