- harness/es.py: append-only event store + проекции (образец — кооп-портал) - harness/levels.py: уровни 1с/1м/1ч/1д, контекст ∝ масштабу - harness/scheduler.py: уровневые потоки, идемпотентные тики, absorbed-стабы - harness/isolated_runner.py + _llm_worker.py: LLM-тик в сабпроцессе (глобальный asyncio-рантайм Strands не переживает 2+ create_harness) - cli.py: init/task/tasks/status/events + requeue (написан самим минутным агентом) - 9router: отдельный ключ sk-simbiot, модель auto (glm-5.3 первым)
506 lines
22 KiB
Text
506 lines
22 KiB
Text
Metadata-Version: 2.5
|
|
Name: strands-agents
|
|
Version: 1.57.1
|
|
Summary: A model-driven approach to building AI agents in just a few lines of code
|
|
Project-URL: Homepage, https://github.com/strands-agents/harness-sdk
|
|
Project-URL: Bug Tracker, https://github.com/strands-agents/harness-sdk/issues
|
|
Project-URL: Documentation, https://strandsagents.com
|
|
Author-email: AWS <opensource@amazon.com>
|
|
License: Apache-2.0
|
|
License-File: LICENSE
|
|
License-File: NOTICE
|
|
Classifier: Development Status :: 5 - Production/Stable
|
|
Classifier: Intended Audience :: Developers
|
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
Classifier: Operating System :: OS Independent
|
|
Classifier: Programming Language :: Python :: 3
|
|
Classifier: Programming Language :: Python :: 3.10
|
|
Classifier: Programming Language :: Python :: 3.11
|
|
Classifier: Programming Language :: Python :: 3.12
|
|
Classifier: Programming Language :: Python :: 3.13
|
|
Classifier: Programming Language :: Python :: 3.14
|
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
Requires-Python: >=3.10
|
|
Requires-Dist: boto3<2.0.0,>=1.26.0
|
|
Requires-Dist: botocore<2.0.0,>=1.29.0
|
|
Requires-Dist: docstring-parser<1.0,>=0.15
|
|
Requires-Dist: httpx<1.0.0,>=0.28.1
|
|
Requires-Dist: jsonschema<5.0.0,>=4.0.0
|
|
Requires-Dist: mcp<2.2,>=1.23.0
|
|
Requires-Dist: opentelemetry-api<2.0.0,>=1.30.0
|
|
Requires-Dist: opentelemetry-instrumentation-threading<1.00b0,>=0.51b0
|
|
Requires-Dist: opentelemetry-sdk<2.0.0,>=1.30.0
|
|
Requires-Dist: pydantic<3.0.0,>=2.4.0
|
|
Requires-Dist: pyyaml<7.0.0,>=6.0.0
|
|
Requires-Dist: typing-extensions<5.0.0,>=4.13.2
|
|
Requires-Dist: watchdog<7.0.0,>=6.0.0
|
|
Provides-Extra: a2a
|
|
Requires-Dist: a2a-sdk<0.4.0,>=0.3.0; extra == 'a2a'
|
|
Requires-Dist: a2a-sdk[sql]<0.4.0,>=0.3.0; extra == 'a2a'
|
|
Requires-Dist: fastapi<1.0.0,>=0.133.0; extra == 'a2a'
|
|
Requires-Dist: httpx<1.0.0,>=0.28.1; extra == 'a2a'
|
|
Requires-Dist: sqlalchemy<2.1.0,>=2.0.0; extra == 'a2a'
|
|
Requires-Dist: starlette<2.0.0,>=1.0.0; extra == 'a2a'
|
|
Requires-Dist: uvicorn<1.0.0,>=0.34.2; extra == 'a2a'
|
|
Provides-Extra: all
|
|
Requires-Dist: a2a-sdk<0.4.0,>=0.3.0; extra == 'all'
|
|
Requires-Dist: a2a-sdk[sql]<0.4.0,>=0.3.0; extra == 'all'
|
|
Requires-Dist: anthropic<1.0.0,>=0.21.0; extra == 'all'
|
|
Requires-Dist: aws-bedrock-token-generator<2.0.0,>=1.1.0; extra == 'all'
|
|
Requires-Dist: aws-sdk-bedrock-runtime[awscrt]<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'all'
|
|
Requires-Dist: awscrt==0.32.2; (python_version >= '3.12') and extra == 'all'
|
|
Requires-Dist: beautifulsoup4<5.0.0,>=4.9.0; extra == 'all'
|
|
Requires-Dist: boto3-stubs[sagemaker-runtime]<2.0.0,>=1.26.0; extra == 'all'
|
|
Requires-Dist: cedar-policy-mcp-schema-generator==0.6.0; extra == 'all'
|
|
Requires-Dist: cedarpy==4.12.0; extra == 'all'
|
|
Requires-Dist: fastapi<1.0.0,>=0.133.0; extra == 'all'
|
|
Requires-Dist: google-genai<3.0.0,>=1.67.0; extra == 'all'
|
|
Requires-Dist: google-genai<3.0.0,>=2.0.0; extra == 'all'
|
|
Requires-Dist: httpx<1.0.0,>=0.28.1; extra == 'all'
|
|
Requires-Dist: litellm<=1.96.0,>=1.75.9; extra == 'all'
|
|
Requires-Dist: llama-api-client<1.0.0,>=0.1.0; extra == 'all'
|
|
Requires-Dist: markdownify<2.0.0,>=1.1.0; extra == 'all'
|
|
Requires-Dist: mistralai<3.0.0,>=2.0.0; extra == 'all'
|
|
Requires-Dist: numpy<3.0.0,>=2.0.0; extra == 'all'
|
|
Requires-Dist: ollama<1.0.0,>=0.4.8; extra == 'all'
|
|
Requires-Dist: openai<3.0.0,>=1.68.0; extra == 'all'
|
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.30.0; extra == 'all'
|
|
Requires-Dist: prompt-toolkit<4.0.0,>=3.0.0; extra == 'all'
|
|
Requires-Dist: pywebrtc-audio<0.3.0,>=0.2.0; extra == 'all'
|
|
Requires-Dist: rich<16.0.0,>=15.0.0; extra == 'all'
|
|
Requires-Dist: smithy-aws-core<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'all'
|
|
Requires-Dist: smithy-core<0.9.0,>=0.8.0; (python_version >= '3.12') and extra == 'all'
|
|
Requires-Dist: smithy-http[awscrt]==0.5.0; (python_version >= '3.12') and extra == 'all'
|
|
Requires-Dist: sphinx-autodoc-typehints<4.0.0,>=1.12.0; extra == 'all'
|
|
Requires-Dist: sphinx-rtd-theme<4.0.0,>=1.0.0; extra == 'all'
|
|
Requires-Dist: sphinx<10.0.0,>=5.0.0; extra == 'all'
|
|
Requires-Dist: sqlalchemy<2.1.0,>=2.0.0; extra == 'all'
|
|
Requires-Dist: starlette<2.0.0,>=1.0.0; extra == 'all'
|
|
Requires-Dist: uvicorn<1.0.0,>=0.34.2; extra == 'all'
|
|
Requires-Dist: websockets<17.0.0,>=16.0.0; extra == 'all'
|
|
Requires-Dist: writer-sdk<4.0.0,>=2.2.0; extra == 'all'
|
|
Provides-Extra: anthropic
|
|
Requires-Dist: anthropic<1.0.0,>=0.21.0; extra == 'anthropic'
|
|
Provides-Extra: bidi
|
|
Requires-Dist: aws-sdk-bedrock-runtime[awscrt]<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'bidi'
|
|
Requires-Dist: awscrt==0.32.2; (python_version >= '3.12') and extra == 'bidi'
|
|
Requires-Dist: smithy-aws-core<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'bidi'
|
|
Requires-Dist: smithy-core<0.9.0,>=0.8.0; (python_version >= '3.12') and extra == 'bidi'
|
|
Requires-Dist: smithy-http[awscrt]==0.5.0; (python_version >= '3.12') and extra == 'bidi'
|
|
Provides-Extra: bidi-aec
|
|
Requires-Dist: numpy<3.0.0,>=2.0.0; extra == 'bidi-aec'
|
|
Requires-Dist: pywebrtc-audio<0.3.0,>=0.2.0; extra == 'bidi-aec'
|
|
Provides-Extra: bidi-all
|
|
Requires-Dist: a2a-sdk<0.4.0,>=0.3.0; extra == 'bidi-all'
|
|
Requires-Dist: a2a-sdk[sql]<0.4.0,>=0.3.0; extra == 'bidi-all'
|
|
Requires-Dist: aws-sdk-bedrock-runtime[awscrt]<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'bidi-all'
|
|
Requires-Dist: awscrt==0.32.2; (python_version >= '3.12') and extra == 'bidi-all'
|
|
Requires-Dist: fastapi<1.0.0,>=0.133.0; extra == 'bidi-all'
|
|
Requires-Dist: google-genai<3.0.0,>=2.0.0; extra == 'bidi-all'
|
|
Requires-Dist: httpx<1.0.0,>=0.28.1; extra == 'bidi-all'
|
|
Requires-Dist: numpy<3.0.0,>=2.0.0; extra == 'bidi-all'
|
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.30.0; extra == 'bidi-all'
|
|
Requires-Dist: prompt-toolkit<4.0.0,>=3.0.0; extra == 'bidi-all'
|
|
Requires-Dist: pywebrtc-audio<0.3.0,>=0.2.0; extra == 'bidi-all'
|
|
Requires-Dist: rich<16.0.0,>=15.0.0; extra == 'bidi-all'
|
|
Requires-Dist: smithy-aws-core<0.12.0,>=0.11.0; (python_version >= '3.12') and extra == 'bidi-all'
|
|
Requires-Dist: smithy-core<0.9.0,>=0.8.0; (python_version >= '3.12') and extra == 'bidi-all'
|
|
Requires-Dist: smithy-http[awscrt]==0.5.0; (python_version >= '3.12') and extra == 'bidi-all'
|
|
Requires-Dist: sphinx-autodoc-typehints<4.0.0,>=1.12.0; extra == 'bidi-all'
|
|
Requires-Dist: sphinx-rtd-theme<4.0.0,>=1.0.0; extra == 'bidi-all'
|
|
Requires-Dist: sphinx<10.0.0,>=5.0.0; extra == 'bidi-all'
|
|
Requires-Dist: sqlalchemy<2.1.0,>=2.0.0; extra == 'bidi-all'
|
|
Requires-Dist: starlette<2.0.0,>=1.0.0; extra == 'bidi-all'
|
|
Requires-Dist: uvicorn<1.0.0,>=0.34.2; extra == 'bidi-all'
|
|
Requires-Dist: websockets<17.0.0,>=16.0.0; extra == 'bidi-all'
|
|
Provides-Extra: bidi-google
|
|
Requires-Dist: google-genai<3.0.0,>=2.0.0; extra == 'bidi-google'
|
|
Provides-Extra: bidi-io
|
|
Requires-Dist: prompt-toolkit<4.0.0,>=3.0.0; extra == 'bidi-io'
|
|
Requires-Dist: rich<16.0.0,>=15.0.0; extra == 'bidi-io'
|
|
Provides-Extra: bidi-openai
|
|
Requires-Dist: websockets<17.0.0,>=16.0.0; extra == 'bidi-openai'
|
|
Provides-Extra: bidi-pyaudio
|
|
Requires-Dist: pyaudio<0.3.0,>=0.2.0; extra == 'bidi-pyaudio'
|
|
Provides-Extra: cedar
|
|
Requires-Dist: cedar-policy-mcp-schema-generator==0.6.0; extra == 'cedar'
|
|
Requires-Dist: cedarpy==4.12.0; extra == 'cedar'
|
|
Provides-Extra: dev
|
|
Requires-Dist: commitizen<5.0.0,>=4.4.0; extra == 'dev'
|
|
Requires-Dist: hatch<2.0.0,>=1.0.0; extra == 'dev'
|
|
Requires-Dist: moto<6.0.0,>=5.1.0; extra == 'dev'
|
|
Requires-Dist: mypy<3.0.0,>=1.15.0; extra == 'dev'
|
|
Requires-Dist: pre-commit<4.7.0,>=3.2.0; extra == 'dev'
|
|
Requires-Dist: pytest-asyncio<1.5.0,>=1.0.0; extra == 'dev'
|
|
Requires-Dist: pytest-cov<8.0.0,>=7.0.0; extra == 'dev'
|
|
Requires-Dist: pytest-timeout<3.0.0,>=2.0.0; extra == 'dev'
|
|
Requires-Dist: pytest-xdist<4.0.0,>=3.0.0; extra == 'dev'
|
|
Requires-Dist: pytest<10.0.0,>=9.0.0; extra == 'dev'
|
|
Requires-Dist: ruff<0.17.0,>=0.16.0; extra == 'dev'
|
|
Requires-Dist: tenacity<10.0.0,>=9.0.0; extra == 'dev'
|
|
Provides-Extra: docs
|
|
Requires-Dist: sphinx-autodoc-typehints<4.0.0,>=1.12.0; extra == 'docs'
|
|
Requires-Dist: sphinx-rtd-theme<4.0.0,>=1.0.0; extra == 'docs'
|
|
Requires-Dist: sphinx<10.0.0,>=5.0.0; extra == 'docs'
|
|
Provides-Extra: gemini
|
|
Requires-Dist: google-genai<3.0.0,>=1.67.0; extra == 'gemini'
|
|
Provides-Extra: litellm
|
|
Requires-Dist: litellm<=1.96.0,>=1.75.9; extra == 'litellm'
|
|
Requires-Dist: openai<3.0.0,>=1.68.0; extra == 'litellm'
|
|
Provides-Extra: llamaapi
|
|
Requires-Dist: llama-api-client<1.0.0,>=0.1.0; extra == 'llamaapi'
|
|
Provides-Extra: mistral
|
|
Requires-Dist: mistralai<3.0.0,>=2.0.0; extra == 'mistral'
|
|
Provides-Extra: ollama
|
|
Requires-Dist: ollama<1.0.0,>=0.4.8; extra == 'ollama'
|
|
Provides-Extra: openai
|
|
Requires-Dist: aws-bedrock-token-generator<2.0.0,>=1.1.0; extra == 'openai'
|
|
Requires-Dist: openai<3.0.0,>=1.68.0; extra == 'openai'
|
|
Provides-Extra: otel
|
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.30.0; extra == 'otel'
|
|
Provides-Extra: sagemaker
|
|
Requires-Dist: boto3-stubs[sagemaker-runtime]<2.0.0,>=1.26.0; extra == 'sagemaker'
|
|
Requires-Dist: openai<3.0.0,>=1.68.0; extra == 'sagemaker'
|
|
Provides-Extra: web-fetch
|
|
Requires-Dist: beautifulsoup4<5.0.0,>=4.9.0; extra == 'web-fetch'
|
|
Requires-Dist: markdownify<2.0.0,>=1.1.0; extra == 'web-fetch'
|
|
Provides-Extra: writer
|
|
Requires-Dist: writer-sdk<4.0.0,>=2.2.0; extra == 'writer'
|
|
Description-Content-Type: text/markdown
|
|
|
|
<div align="center">
|
|
<div>
|
|
<a href="https://strandsagents.com">
|
|
<picture>
|
|
<source media="(prefers-color-scheme: dark)" srcset="https://strandsagents.com/latest/assets/wordmark-github-dark.svg">
|
|
<img src="https://strandsagents.com/latest/assets/wordmark-github-light.svg" alt="Strands" width="320">
|
|
</picture>
|
|
</a>
|
|
</div>
|
|
|
|
<h1>
|
|
Strands Agents - Python SDK
|
|
</h1>
|
|
|
|
<h2>
|
|
A model-driven approach to building AI agents in just a few lines of code.
|
|
</h2>
|
|
|
|
<div align="center">
|
|
<a href="https://github.com/strands-agents/harness-sdk/graphs/commit-activity"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/strands-agents/harness-sdk"/></a>
|
|
<a href="https://github.com/strands-agents/harness-sdk/issues"><img alt="GitHub open issues" src="https://img.shields.io/github/issues/strands-agents/harness-sdk"/></a>
|
|
<a href="https://github.com/strands-agents/harness-sdk/pulls"><img alt="GitHub open pull requests" src="https://img.shields.io/github/issues-pr/strands-agents/harness-sdk"/></a>
|
|
<a href="https://github.com/strands-agents/harness-sdk/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/strands-agents/harness-sdk"/></a>
|
|
<a href="https://pypi.org/project/strands-agents/"><img alt="PyPI version" src="https://img.shields.io/pypi/v/strands-agents"/></a>
|
|
<a href="https://python.org"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/strands-agents"/></a>
|
|
<a href="https://discord.gg/strands"><img alt="Strands Discord" src="https://img.shields.io/badge/Discord-Strands-5865F2?logo=discord&logoColor=white"/></a>
|
|
</div>
|
|
|
|
<p>
|
|
<a href="https://strandsagents.com/">Documentation</a>
|
|
◆ <a href="https://github.com/strands-agents/samples">Samples</a>
|
|
◆ <a href="https://github.com/strands-agents/tools">Tools</a>
|
|
◆ <a href="https://github.com/strands-agents/harness-sdk/tree/main/strands-mcp">MCP Server</a>
|
|
</p>
|
|
</div>
|
|
|
|
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
|
|
|
|
Connect to 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")
|
|
```
|
|
|
|
The SDK works with both major versions of the `mcp` package through a built-in compatibility layer, so most code that uses `MCPClient` runs unchanged on either version. A fresh install resolves to mcp 2.x, and pinning `mcp<2` keeps you on 1.x. See [docs/MCP_VERSIONS.md](./docs/MCP_VERSIONS.md) for support status, the behavior differences on 2.x, and migration notes.
|
|
|
|
### 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/docs/user-guide/concepts/model-providers/amazon-bedrock/)
|
|
- [Anthropic](https://strandsagents.com/docs/user-guide/concepts/model-providers/anthropic/)
|
|
- [Gemini](https://strandsagents.com/docs/user-guide/concepts/model-providers/gemini/)
|
|
- [Cohere](https://strandsagents.com/docs/user-guide/concepts/model-providers/cohere/)
|
|
- [LiteLLM](https://strandsagents.com/docs/user-guide/concepts/model-providers/litellm/)
|
|
- [llama.cpp](https://strandsagents.com/docs/user-guide/concepts/model-providers/llamacpp/)
|
|
- [LlamaAPI](https://strandsagents.com/docs/user-guide/concepts/model-providers/llamaapi/)
|
|
- [MistralAI](https://strandsagents.com/docs/user-guide/concepts/model-providers/mistral/)
|
|
- [Ollama](https://strandsagents.com/docs/user-guide/concepts/model-providers/ollama/)
|
|
- [OpenAI](https://strandsagents.com/docs/user-guide/concepts/model-providers/openai/)
|
|
- [OpenAI Responses API](https://strandsagents.com/docs/user-guide/concepts/model-providers/openai/)
|
|
- [SageMaker](https://strandsagents.com/docs/user-guide/concepts/model-providers/sagemaker/)
|
|
- [Writer](https://strandsagents.com/docs/user-guide/concepts/model-providers/writer/)
|
|
|
|
Custom providers can be implemented using [Custom Providers](https://strandsagents.com/docs/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/docs/user-guide/concepts/bidirectional-streaming/quickstart/) guide.
|
|
|
|
**Supported Model Providers:**
|
|
- Amazon Bedrock Nova Sonic
|
|
- Google Gemini Live
|
|
- OpenAI Realtime API
|
|
|
|
**Installation:**
|
|
|
|
```bash
|
|
# Server-side only (no audio I/O dependencies)
|
|
pip install strands-agents[bidi]
|
|
|
|
# With all portable Bidi providers, terminal I/O, and audio processing (no local audio devices)
|
|
pip install strands-agents[bidi-all]
|
|
|
|
# For local microphone/speaker access, install PortAudio for your OS first, then:
|
|
pip install strands-agents[bidi,bidi-io,bidi-pyaudio]
|
|
```
|
|
|
|
> **Note**: Bedrock Nova Sonic requires Python 3.12+ due to its experimental AWS SDK dependency.
|
|
|
|
**Quick Example:**
|
|
|
|
```python
|
|
import asyncio
|
|
from strands.experimental.bidi.agent import BidiAgent
|
|
from strands.experimental.bidi.models import BedrockNovaSonicModel
|
|
from strands.experimental.bidi.io import AudioIO
|
|
from strands_tools import calculator, stop
|
|
|
|
async def main():
|
|
# Create bidirectional agent with Nova Sonic v2
|
|
model = BedrockNovaSonicModel(model_id="amazon.nova-2-sonic-v1:0")
|
|
agent = BidiAgent(model=model, tools=[calculator, stop])
|
|
|
|
# Setup audio I/O (local audio requires the bidi-pyaudio extra)
|
|
audio_io = AudioIO()
|
|
|
|
# Run with real-time audio streaming and terminal transcripts
|
|
# stop tool allows user to verbally stop agent execution
|
|
await agent.run(
|
|
inputs=[audio_io.input()],
|
|
outputs=[audio_io.output()]
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|
|
```
|
|
|
|
> **Note**: `ConsoleIO` is included with the `bidi-io` extra. `AudioIO` requires
|
|
> the `bidi-io` and `bidi-pyaudio` extras plus the PortAudio system library. 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 streams using the `InputStream` and `OutputStream` protocols.
|
|
|
|
**Configuration Options:**
|
|
|
|
```python
|
|
from strands.experimental.bidi.models import BedrockNovaSonicModel
|
|
|
|
# Configure audio streams and Nova Sonic session parameters.
|
|
model = BedrockNovaSonicModel(
|
|
model_id="amazon.nova-2-sonic-v1:0",
|
|
audio={
|
|
"input": {"sample_rate": 16000},
|
|
"output": {"sample_rate": 16000},
|
|
},
|
|
voice="matthew",
|
|
params={
|
|
"turnDetectionConfiguration": {
|
|
"endpointingSensitivity": "MEDIUM"
|
|
},
|
|
"inferenceConfiguration": {
|
|
"maxTokens": 2048,
|
|
"temperature": 0.7
|
|
},
|
|
},
|
|
)
|
|
|
|
# Configure I/O devices
|
|
audio_io = AudioIO(
|
|
input_device_index=0, # Specific microphone
|
|
output_device_index=1, # Specific speaker
|
|
input_buffer_size=10,
|
|
output_buffer_size=10
|
|
)
|
|
```
|
|
|
|
## Documentation
|
|
|
|
For detailed guidance & examples, explore our documentation:
|
|
|
|
- [User Guide](https://strandsagents.com/)
|
|
- [Quick Start Guide](https://strandsagents.com/docs/user-guide/quickstart/)
|
|
- [Agent Loop](https://strandsagents.com/docs/user-guide/concepts/agents/agent-loop/)
|
|
- [Examples](https://strandsagents.com/docs/examples/)
|
|
- [API Reference](https://strandsagents.com/docs/api/python/strands.agent.agent/)
|
|
- [Production & Deployment Guide](https://strandsagents.com/docs/user-guide/deploy/operating-agents-in-production/)
|
|
|
|
## Development
|
|
|
|
```bash
|
|
pip install hatch
|
|
hatch test # run unit tests
|
|
hatch fmt # format & lint
|
|
```
|
|
|
|
## Contributing ❤️
|
|
|
|
We welcome contributions! See our [Contributing Guide](https://github.com/strands-agents/harness-sdk/blob/main/CONTRIBUTING.md) for details on:
|
|
- Reporting bugs & features
|
|
- Development setup
|
|
- Contributing via Pull Requests
|
|
- Code of Conduct
|
|
- Reporting of security issues
|
|
|
|
## Stay in touch with the team
|
|
Come meet the Strands team and other users on [**Discord**](https://discord.com/invite/strands)
|
|
|
|
## License
|
|
|
|
This project is licensed under the Apache License 2.0 - see the [LICENSE](https://github.com/strands-agents/harness-sdk/blob/main/LICENSE.APACHE) file for details.
|
|
|
|
## Security
|
|
|
|
See [CONTRIBUTING](https://github.com/strands-agents/harness-sdk/blob/main/CONTRIBUTING.md#security-issue-notifications) for more information.
|