Daimon
A Rust-native AI agent framework for building LLM-powered agents with tool use, memory, and streaming.
Daimon implements the ReAct (Reason-Act-Observe) pattern: the agent calls a model, optionally invokes tools, observes results, and repeats until it produces a final response. It is designed to be easy to use while leveraging Rust's type system, async runtime, and performance characteristics.
Features
- ReAct agent loop with configurable iteration limits
- Multiple LLM providers behind feature flags — OpenAI, Anthropic, AWS Bedrock
- Tool system with async execution, parallel tool calls, and a typed registry
- Streaming with full ReAct loop support (tool calls accumulate and re-invoke within a single stream)
- Conversation memory with pluggable backends (sliding window included)
- Lifecycle hooks for observability and control
- Cancellation via
tokio_util::CancellationToken - Tracing instrumentation on all agent and provider operations
- Retry logic with exponential backoff for transient provider errors
Quick Start
Add Daimon to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Create an agent and prompt it:
use *;
async
Tools
Define tools by implementing the Tool trait:
use *;
;
async
Streaming
Stream responses token-by-token with the full ReAct loop:
use *;
async
Feature Flags
| Feature | Default | Description |
|---|---|---|
openai |
Yes | OpenAI Chat Completions API |
anthropic |
Yes | Anthropic Messages API |
bedrock |
No | AWS Bedrock Converse API |
full |
No | All providers |
The core framework compiles with no features enabled. Enable only the providers you need:
# Only Anthropic
= { = "0.1", = false, = ["anthropic"] }
# All providers
= { = "0.1", = ["full"] }
# Core only (bring your own Model impl)
= { = "0.1", = false }
Provider Configuration
All providers support configurable timeout, retries, and provider-specific options:
use Duration;
// OpenAI with custom settings
let model = new
.with_timeout
.with_max_retries
.with_response_format
.with_parallel_tool_calls;
// Anthropic with prompt caching
let model = new
.with_timeout
.with_prompt_caching;
// AWS Bedrock with guardrails
let model = new
.with_guardrail;
Agent Configuration
use *;
let agent = builder
.model // required
.system_prompt // optional system prompt
.tool // register tools
.tool
.memory // custom memory (default: 50 messages)
.hooks // lifecycle hooks
.max_iterations // default: 25
.temperature // sampling temperature
.max_tokens // max output tokens
.build?;
// Standard prompt
let response = agent.prompt.await?;
println!;
println!;
// With cancellation
let cancel = new;
let response = agent.prompt_with_cancellation.await?;
// With pre-built messages
let messages = vec!;
let response = agent.prompt_with_messages.await?;
Architecture
┌──────────────────────────────────────────────────┐
│ Agent │
│ ┌────────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Model │ │ Tools │ │ Memory │ │
│ │ (trait) │ │ Registry │ │ (trait) │ │
│ └─────┬──────┘ └────┬─────┘ └──────┬───────┘ │
│ │ │ │ │
│ ┌─────┴──────────────┴───────────────┴───────┐ │
│ │ ReAct Loop │ │
│ │ 1. Load memory → build request │ │
│ │ 2. Call model │ │
│ │ 3. Tool calls? → execute (parallel) → 2 │ │
│ │ 4. Final response → save to memory │ │
│ └────────────────────────────────────────────┘ │
│ │ │
│ ┌─────┴──────┐ ┌──────────┐ │
│ │ Hooks │ │ Streaming │ │
│ │ (lifecycle)│ │ Events │ │
│ └────────────┘ └──────────┘ │
└──────────────────────────────────────────────────┘
Minimum Supported Rust Version
Rust 1.85 (edition 2024).
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
See CONTRIBUTING.md for development setup, coding standards, and contribution guidelines. Note that AI-assisted contributions must include proper attribution.