Why Rust Deep Agents?
Building AI agents shouldn't mean sacrificing performance or type safety. While Python frameworks dominate the AI space, Rust Deep Agents SDK brings the reliability and speed of Rust to agent development.
Comparison with Alternatives
| Feature | Rust Deep Agents | LangChain | CrewAI | AutoGen |
|---|---|---|---|---|
| Language | Rust | Python | Python | Python |
| Type Safety | Compile-time | Runtime | Runtime | Runtime |
| Performance | Native speed | Interpreted | Interpreted | Interpreted |
| Memory Safety | Guaranteed | GC-dependent | GC-dependent | GC-dependent |
| Async/Concurrent | Tokio-native | asyncio | asyncio | asyncio |
| Tool Macro | #[tool] |
Decorators | Decorators | Manual |
| Token Tracking | Built-in | Callbacks | Manual | Manual |
| HITL Workflows | Native | Plugin | Limited | Plugin |
| PII Protection | Automatic | Manual | Manual | Manual |
Ideal Use Cases
- Enterprise applications requiring reliability and compliance
- High-throughput systems processing thousands of agent requests
- Security-critical environments where memory safety matters
- Cloud-native deployments on AWS Lambda, ECS, or Kubernetes
- Rust teams who want AI capabilities without Python dependencies
Features
Multi-Provider LLM Support
The SDK is model-agnostic — pass any model string supported by the provider:
- OpenAI: Any model (e.g.,
gpt-5.2,gpt-4o,o1-pro,gpt-4o-mini) - Anthropic: Any model (e.g.,
claude-opus-4.5,claude-sonnet-4.5,claude-haiku-4.5) - Google Gemini: Any model (e.g.,
gemini-2.5-pro,gemini-2.5-flash,gemini-2.0-flash)
Ergonomic Tool System
#[tool]macro for zero-boilerplate tool definitions- Automatic JSON Schema generation
- Support for sync and async tools
Flexible Persistence
- In-memory storage for development
- Redis for production deployments
- PostgreSQL for enterprise environments
- DynamoDB for AWS-native architectures
Token Tracking and Cost Control
- Real-time usage monitoring
- Cost estimation per request
- Budget alerts and limits
Human-in-the-Loop (HITL)
- Configurable approval workflows
- Tool-level interrupt policies
- Audit trail for compliance
Enterprise Security
- Automatic PII sanitization
- Sensitive field redaction
- Compliance-ready event logging
Quick Start
Installation
Add to your Cargo.toml:
[]
= "0.0.28"
= { = "1.0", = ["full"] }
= "1.0"
Your First Agent
use ;
use AgentStateSnapshot;
use tool;
use Arc;
// Define a tool with a simple macro
async
Examples
Explore comprehensive examples demonstrating SDK capabilities:
| Example | Description | Complexity |
|---|---|---|
simple-agent |
Basic agent with OpenAI | Beginner |
tool-test |
Custom tools with #[tool] macro |
Beginner |
anthropic-tools-test |
Using Claude models | Beginner |
gemini-tools-test |
Using Gemini models | Beginner |
token-tracking-demo |
Monitor usage and costs | Intermediate |
event-system-demo |
Real-time event broadcasting | Intermediate |
checkpointer-demo |
State persistence | Intermediate |
hitl-demo |
Human-in-the-loop basics | Intermediate |
hitl-financial-advisor |
Production HITL workflow | Advanced |
subagent-demo |
Multi-agent delegation | Advanced |
streaming-events-demo |
SSE/WebSocket streaming | Advanced |
automotive-web-service |
Full-stack web application | Advanced |
Running Examples
Architecture
rust-deep-agents-sdk/
├── crates/
│ ├── agents-core/ # Core traits, messages, state models
│ ├── agents-runtime/ # Execution engine, builders, middleware
│ ├── agents-toolkit/ # Built-in tools and utilities
│ ├── agents-macros/ # #[tool] procedural macro
│ ├── agents-sdk/ # Unified SDK with feature flags
│ ├── agents-aws/ # AWS integrations (DynamoDB, Secrets)
│ └── agents-persistence/ # Redis, PostgreSQL backends
├── examples/ # Working examples and demos
├── docs/ # Documentation and guides
└── deploy/ # Terraform modules for AWS
Provider Support
The SDK is model-agnostic — you can use any model string supported by the provider's API.
| Provider | Example Models | Status |
|---|---|---|
| OpenAI | gpt-5.2, gpt-4o, o1-pro, o1-mini, gpt-4o-mini |
Stable |
| Anthropic | claude-opus-4.5, claude-sonnet-4.5, claude-haiku-4.5 |
Stable |
| Google Gemini | gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash |
Stable |
Note: Model availability depends on your API access. The SDK passes your model string directly to the provider — any model they support will work.
Middleware Stack
The SDK includes a composable middleware system:
- Token Tracking — Usage and cost monitoring
- HITL — Human approval workflows
- Planning — Todo list management
- Summarization — Context window management
- PII Sanitization — Automatic data protection
- SubAgent — Task delegation to specialized agents
Advanced Usage
use ;
use Arc;
// OpenAI
let openai = new;
// Anthropic Claude
let claude = new;
// Google Gemini
let gemini = new;
// Use any provider with the same builder API
let agent = new
.with_model
.build?;
use ;
let token_config = TokenTrackingConfig ;
let agent = new
.with_model
.with_token_tracking_config
.build?;
use ;
use HashMap;
let mut policies = new;
policies.insert;
let agent = new
.with_model
.with_tool_interrupts
.with_checkpointer
.build?;
// Handle interrupts
if let Some = agent.current_interrupt.await?
use ;
use RedisCheckpointer;
use Arc;
// Development: In-memory
let checkpointer = new;
// Production: Redis
let checkpointer = new;
let agent = new
.with_model
.with_checkpointer
.build?;
// Save and restore conversation state
let thread_id = "user-123";
agent.save_state.await?;
agent.load_state.await?;
use ;
use AgentEvent;
use async_trait;
let agent = new
.with_model
.with_event_broadcaster
.build?;
use ;
let researcher = SubAgentConfig ;
let writer = SubAgentConfig ;
let agent = new
.with_model
.with_subagent
.with_subagent
.with_auto_general_purpose
.build?;
Feature Flags
[]
# Default: includes toolkit
= "0.0.28"
# Minimal: core only
= { = "0.0.28", = false }
# With persistence
= { = "0.0.28", = ["redis"] }
= { = "0.0.28", = ["postgres"] }
# With AWS
= { = "0.0.28", = ["aws", "dynamodb"] }
# Everything
= { = "0.0.28", = ["full"] }
| Feature | Description |
|---|---|
toolkit |
Built-in tools (default) |
redis |
Redis persistence backend |
postgres |
PostgreSQL persistence backend |
dynamodb |
DynamoDB persistence backend |
aws |
AWS integrations (Secrets Manager, etc.) |
full |
All features enabled |
Development
Environment Variables
# Optional: for web search
Contributing
We welcome contributions of all kinds:
- Bug reports and fixes
- Feature requests and implementations
- Documentation improvements
- Test coverage
Please read our Contributing Guide to get started.
New contributors can look for issues labeled good first issue.
Roadmap
Providers
- AWS Bedrock provider (Claude, Titan, Llama)
- Ollama for local/self-hosted models
- Azure OpenAI Service
Features
- Custom sub-agent execution graphs
- Advanced state features (encryption, migrations)
- Enhanced tool composition and validation
- WebAssembly support
- OpenTelemetry integration
See the full roadmap for details.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.