Expand description
§AI Agents Framework
One YAML = Any Agent. A Rust framework for building AI agents from a single YAML specification. No code required for common use cases.
§Quick Start
§From YAML
ⓘ
use ai_agents::{Agent, AgentBuilder};
#[tokio::main]
async fn main() -> ai_agents::Result<()> {
let agent = AgentBuilder::from_yaml_file("agent.yaml")?
.auto_configure_llms()?
.build()?;
let response = agent.chat("Hello!").await?;
println!("{}", response.content);
Ok(())
}§From Rust API
ⓘ
use ai_agents::{Agent, AgentBuilder, UnifiedLLMProvider, ProviderType};
use std::sync::Arc;
#[tokio::main]
async fn main() -> ai_agents::Result<()> {
let llm = UnifiedLLMProvider::from_env(ProviderType::OpenAI, "gpt-4.1-nano")?;
let agent = AgentBuilder::new()
.system_prompt("You are a helpful assistant.")
.llm(Arc::new(llm))
.build()?;
let response = agent.chat("Hello!").await?;
println!("{}", response.content);
Ok(())
}§Modules
| Module | Description |
|---|---|
agent | Agent builder, runtime, streaming, and response types |
llm | LLM providers and registry |
memory | Conversation memory with compression and token budgeting |
tools | Built-in tools and extensible tool registry |
state | Hierarchical state machine with LLM-evaluated transitions |
context | Dynamic context injection from multiple sources |
skill | Reusable workflows with LLM-based intent routing |
hitl | Human-in-the-loop approval system |
reasoning | Chain-of-thought, ReAct, plan-and-execute modes |
disambiguation | Intent ambiguity detection and clarification |
persistence | SQLite, Redis, and file storage backends |
process | Input/output processing pipeline |
recovery | Error recovery with retry and fallback strategies |
hooks | Lifecycle event hooks for logging, metrics, monitoring |
spec | YAML agent specification types |
template | Template loading with Jinja2 rendering and inheritance |
spawner | Dynamic agent spawning, registry, and inter-agent messaging |
§Feature Flags
| Flag | Description |
|---|---|
sqlite | SQLite storage backend |
redis-storage | Redis storage backend |
http-context | HTTP context source for dynamic context injection |
full-storage | All storage backends (sqlite + redis-storage) |
full | All optional features enabled |
Re-exports§
pub use memory::create_memory;pub use memory::create_memory_from_config;pub use memory::create_memory_from_config_with_llm;pub use template::TemplateLoader;pub use persistence::create_storage;
Modules§
- agent
- context
- disambiguation
- dot_
path - error
- hitl
- hooks
- llm
- mcp
- MCP (Model Context Protocol) integration types.
- memory
- orchestration
- persistence
- persona
- process
- reasoning
- recovery
- skill
- spawner
- Dynamic agent spawning, registry, and inter-agent messaging.
- spec
- state
- template
- tool_
security - tools
Structs§
- Agent
Builder - Agent
Info - Agent
Response - Agent
Snapshot - Snapshot of agent state for persistence
- Agent
Spec - Ambiguity
Detection Result - Result of ambiguity detection
- Ambiguity
Detector - LLM-based detector for ambiguous user inputs
- Approval
Condition - Approval
Request - Auto
Approve Handler - Builtin
Provider Config - ByRole
Filter - Cache
Config - Cache configuration for disambiguation results
- Calculator
Tool - This Tool is for development purposes only. It evaluates mathematical expressions. It is not intended for production use.
- Chat
Message - Clarification
Config - Clarification configuration - how to ask for clarity
- Clarification
Generator - LLM-based generator for clarification questions
- Clarification
Option - An option for clarification
- Clarification
Question - Generated clarification question
- Compacting
Memory - Compacting
Memory Config - Composite
Hooks - Compression
Event - Condition
Evaluator - Context
Config - Context configuration - what information helps disambiguation
- Context
Extractor - Extract structured data from conversation into context via LLM.
- Context
Manager - Conversation
Context - Criterion
Result - Date
Time Tool - Detection
Config - Detection configuration - how to identify ambiguous inputs
- Disambiguation
Config - Main disambiguation configuration
- Disambiguation
Context - Context for disambiguation evaluation
- Disambiguation
Manager - Manager orchestrating the full disambiguation flow
- Echo
Tool - Error
Recovery Config - Top-level error recovery configuration for an agent. Controls retry, LLM failure handling, tool failure handling, and parse error handling.
- Evaluation
Context - Evaluation
Result - Fact
Extracted Event - File
Storage - File
Storage Config - File
Tool - Guard
Only Evaluator - HITL
Config - HITL
Engine - Hook
Timer - Http
Tool - InMemory
Store - Json
Tool - Keep
Recent Filter - LLMConfig
- Configuration for LLM provider
- LLMRegistry
- LLMResponse
- LLMSelector
- LLMSummarizer
- LLMTransition
Evaluator - LlmGenerate
Config - Localized
Handler - Logging
Hooks - Math
Tool - Memory
Budget Event - Memory
Budget State - Memory
Compress Event - Memory
Config - Memory
Evict Event - Memory
Snapshot - Snapshot of memory state for persistence
- Memory
Token Budget - Message
Language Config - Message
Resolver - Noop
Hooks - Noop
Summarizer - Parallel
Tools Config - Plan
- Plan
Available Actions - Plan
Reflection Config - Plan
Step - Planning
Config - Process
Config - Process
Data - Process
Processor - Provider
Policy Config - Policy configuration for a provider
- Provider
Security Config - Providers
Config - Random
Tool - Reasoning
Config - Reasoning
Metadata - Recovery
Manager - Redis
Storage Config - Reflection
Attempt - Reflection
Config - Reflection
Metadata - Reject
AllHandler - Runtime
Agent - Session
Info - Session
Metadata - Session
Query - SimpleLLM
Getter - Skill
Definition - Skill
Disambiguation Override - Skill-level disambiguation override
- Skill
Executor - Skill
Loader - Skill
Router - Skip
Pattern Filter - Spawned
Agent Entry - Minimal record of a spawned agent for session persistence.
- Spec
Tool Policy Config - Policy configuration for a tool within a provider
- Sqlite
Storage Config - State
Approval Config - State
Config - State
Definition - State
Disambiguation Override - State-level disambiguation override
- State
Machine - State
Machine Snapshot - State
Matcher - State
Transition Event - Streaming
Config - Configuration for streaming behavior
- Template
Renderer - Template
Tool - Text
Tool - Time
Matcher - Token
Allocation - Tool
Aliases - Tool
Aliases Config - Global tool aliases configuration
- Tool
Approval Config - Tool
Call Record - Tool
Context - Tool
Descriptor - Tool
Metadata - Tool
Policy Config - Tool
Registry - Tool
Result - Tool
Security Config - Tool
Security Engine - Transition
- Transition
Context - UnifiedLLM
Provider - Yaml
Provider Config - Yaml
Tool Config
Enums§
- Agent
Error - Main error type for the framework
- Ambiguity
Aspect - Aspects of ambiguity to detect
- Ambiguity
Type - Type of ambiguity detected
- Approval
Message - Approval
Result - Approval
Trigger - Builtin
Source - Clarification
Parse Result - Result of parsing user’s clarification response
- Clarification
Style - Style of clarification questions
- Compare
Op - Compress
Result - Context
Matcher - Context
Source - Disambiguation
Result - Disambiguation processing result
- Eviction
Reason - Filter
Config - Selects which messages are passed to the summarizer during context compression.
- Guard
Conditions - HITL
Check Result - LLMProvider
Type - Provider type enum
- MaxAttempts
Action - Action to take when max clarification attempts reached
- Message
Language Strategy - Overflow
Strategy - Plan
Action - Plan
Status - Prompt
Mode - Provider
Health - Provider
Type - Provider type enum
- Reasoning
Mode - Reasoning
Output - Reflection
Mode - Refresh
Policy - Role
- Security
Check Result - Session
Order By - Skill
Ref - Skill
Step - Skip
Condition - Conditions when to skip disambiguation
- State
Action - State
Approval Trigger - Step
Failure Action - Step
Status - Storage
Config - Storage configuration using tagged enum for type safety and extensibility
- Stream
Chunk - Represents a chunk of streamed response from the agent
- String
OrList - Timeout
Action - Tool
Condition - Tool
Provider Error - Tool
Provider Type - ToolRef
- Transition
Guard - Trust
Level
Traits§
- Agent
- Agent
Hooks - Agent
Storage - Core storage trait for persisting agent state.
- Approval
Handler - Handler for human-in-the-loop approval requests.
- Context
Provider - LLMGetter
- LLMProvider
- Core LLM provider trait.
- Memory
- Extended memory trait that preserves the original interface.
- Message
Filter - Summarizer
- Summarizes conversation messages for memory compression.
- Tool
- Core tool trait for external capabilities.
- Tool
Provider - Transition
Evaluator
Functions§
- create_
builtin_ registry - create_
handler - create_
localized_ handler - estimate_
message_ tokens - estimate_
tokens - Language-aware token estimation for multi-language support
- resolve_
best_ language - resolve_
tool_ message
Type Aliases§
- Result
- Result type alias for agent operations
- Tool
Config - Backward compatibility alias — existing code using
ToolConfigkeeps working.