AWS contributions for Deep Agents
Project description
deepagents-contrib-aws
AWS backend implementations for the deepagents framework.
Backends
S3Backend
An S3-backed implementation of the BackendProtocol that persists agent workspace files in Amazon S3. Supports all eight protocol methods: ls, read, write, edit, grep, glob, upload_files, download_files.
Installation
pip install deepagents-contrib-aws
Quick Start
From constructor
Minimal — S3 client is created implicitly; region and credentials are picked up from environment variables or ~/.aws/config:
from deepagents_contrib_aws import S3Backend
backend = S3Backend(bucket="my-bucket", prefix="agent/workspace/")
Explicit — pass a pre-configured boto3 client and region (useful for custom endpoints like LocalStack, S3-compatible storage, or reusing an existing session):
import boto3
from deepagents_contrib_aws import S3Backend
client = boto3.client("s3", region_name="us-west-2")
backend = S3Backend(
bucket="my-bucket",
prefix="agent/workspace/",
client=client,
region_name="us-west-2",
)
From environment variables
export S3_BACKEND_BUCKET=my-bucket
export S3_BACKEND_PREFIX=agent/workspace/
export AWS_REGION=us-west-2 # or AWS_DEFAULT_REGION
from deepagents_contrib_aws import S3Backend
backend = S3Backend.from_env()
With deepagents
from deepagents import create_deep_agent
from deepagents_contrib_aws import S3Backend
backend = S3Backend.from_env()
agent = create_deep_agent(backend=backend)
Basic operations
backend = S3Backend(bucket="my-bucket", prefix="demo/")
# Write a file (errors if file already exists)
result = backend.write("/hello.py", "print('hello')")
# Read it back (with line-based pagination)
result = backend.read("/hello.py")
# Edit it (exact string replacement)
result = backend.edit("/hello.py", "hello", "world")
# List directory
result = backend.ls("/")
# Search file contents (literal text, not regex)
result = backend.grep("world", path="/")
# Find files by pattern
result = backend.glob("*.py")
# Bulk upload
result = backend.upload_files([("/a.txt", b"content a"), ("/b.txt", b"content b")])
# Bulk download
result = backend.download_files(["/a.txt", "/b.txt"])
Configuration
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
bucket |
str |
required | S3 bucket name |
prefix |
str |
"" |
Key prefix for all objects (e.g. "agent/workspace/") |
client |
boto3 S3 client | None |
Optional pre-configured boto3 client |
region_name |
str |
None |
AWS region for the default client |
Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
S3_BACKEND_BUCKET |
Yes (for from_env()) |
-- | S3 bucket name |
S3_BACKEND_PREFIX |
No | "" |
Key prefix for all objects |
AWS_REGION |
No | -- | AWS region (checked first; auto-set by AWS Lambda) |
AWS_DEFAULT_REGION |
No | -- | AWS region (standard boto3 fallback if AWS_REGION is not set) |
AWS credentials are resolved via the standard boto3 credential chain: environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), shared credentials file (~/.aws/credentials), AWS SSO, or IAM role.
Development
Setup
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create venv and install all dependencies
uv sync
# Lint
uv run ruff check src/ tests/
# Build
uv build
Testing
The project has two test suites: unit tests (mocked S3 via moto) and integration tests (real S3 bucket).
Unit tests
Unit tests use moto to mock all S3 API calls. No AWS credentials or network access required.
uv run pytest
This runs 58 tests covering all 8 protocol methods, path helpers, error mapping, from_env() factory, and edge cases (binary files, empty files, pagination, partial batch failures).
Integration tests
Integration tests run against a real S3 bucket to validate actual AWS behavior (pagination, error codes, eventual consistency). They are skipped by default.
Prerequisites:
- An existing S3 bucket with read/write access
- AWS credentials configured via any standard method:
- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - Shared credentials file (
~/.aws/credentials) - AWS SSO (
aws sso login) - IAM role (EC2, ECS, Lambda)
- Environment variables (
- IAM permissions on the test bucket:
s3:GetObjects3:PutObjects3:DeleteObject(for cleanup after tests)s3:ListBucket
Running:
S3_TEST_BUCKET=your-bucket-name uv run pytest -m integration
Optionally set the region if the bucket is not in us-east-1:
S3_TEST_BUCKET=your-bucket-name AWS_DEFAULT_REGION=us-west-2 uv run pytest -m integration
Run both unit and integration tests together:
S3_TEST_BUCKET=your-bucket-name uv run pytest -m ""
Test isolation: Integration tests create objects under a unique prefix (integration-test-<uuid>/) and clean up after themselves. They will not leave artifacts in your bucket.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepagents_contrib_aws-0.1.1.tar.gz.
File metadata
- Download URL: deepagents_contrib_aws-0.1.1.tar.gz
- Upload date:
- Size: 121.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c36ff891661bbed8bfdaca0d59338b3f8b4fb7004cc5edc8ef87224ca378ff9
|
|
| MD5 |
53cc872262583b6e9f8de5018d1d105a
|
|
| BLAKE2b-256 |
28507a343a46232363a35e7e98b39dd6ba0f65ab364c1b19bc1cc520e2c9dac9
|
File details
Details for the file deepagents_contrib_aws-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deepagents_contrib_aws-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0f26acd0938da4b94f02c2a55fa78e6f55d817d429444d53cff5ac92273df6a
|
|
| MD5 |
08afb3eaa4a44f10cd9d873e8845c78d
|
|
| BLAKE2b-256 |
94bf18101bdaee139e3d5abefdf8d3da11697c58925608b84f5701bc7343dfa8
|