1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! # agent-runtime
//!
//! A unified Tokio agent runtime that brings together orchestration, memory,
//! knowledge graph, and a ReAct agent loop in a single crate.
//!
//! ## Feature Flags
//!
//! | Feature | Content |
//! |---------|---------|
//! | `orchestrator` (default) | Circuit breaker, retry, dedup, backpressure, pipeline |
//! | `memory` (default) | Episodic, semantic, working memory + decay |
//! | `graph` (default) | In-memory knowledge graph (BFS/DFS/shortest-path) |
//! | `wasm` | ReAct agent loop, tool registry |
//! | `full` | All of the above |
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use llm_agent_runtime::prelude::*;
//!
//! // build() is now infallible — the typestate pattern enforces that
//! // with_agent_config() is called before build() at compile time.
//! let runtime = AgentRuntime::builder()
//! .with_agent_config(AgentConfig::new(5, "my-model"))
//! .build();
//!
//! // run_agent is async; drive it with your async runtime.
//! // tokio::runtime::Runtime::new().unwrap().block_on(async {
//! // let session = runtime
//! // .run_agent(AgentId::new("agent-1"), "Hello", |_ctx: String| async {
//! // "Thought: done\nAction: FINAL_ANSWER hi".to_string()
//! // })
//! // .await
//! // .unwrap();
//! // println!("Steps: {}", session.step_count());
//! // });
//! ```
//!
//! ## Extension Points
//!
//! The primary extension point is the [`PersistenceBackend`] trait (enabled by
//! the `persistence` feature). Implement it to persist agent sessions and
//! per-step checkpoints to any storage backend — disk, Redis, S3, or a
//! database. The bundled [`FilePersistenceBackend`] stores each checkpoint as a
//! `<key>.bin` file in a local directory and serves as a reference
//! implementation.
//!
//! Additional extension points:
//! - [`LlmProvider`] (`providers` feature) — plug in any LLM API.
//! - `CircuitBreakerBackend` (`redis-circuit-breaker` feature) — distributed
//! circuit-breaker state via Redis.
//!
//! ## Upstream Crates
//!
//! This crate implements standalone versions of the APIs from:
//! - `tokio-prompt-orchestrator` (Mattbusel/tokio-prompt-orchestrator)
//! - `tokio-agent-memory` (Mattbusel/tokio-agent-memory)
//! - `mem-graph` (Mattbusel/mem-graph)
//! - `wasm-agent` (Mattbusel/wasm-agent)
//! - `tokio-memory` (Mattbusel/tokio-memory)
// Enforce documentation on all public items in production code.
// ── Public modules ─────────────────────────────────────────────────────────
// ── Top-level re-exports ────────────────────────────────────────────────────
pub use AgentRuntimeError;
pub use ;
// Core identifier types — always available.
pub use ;
// Memory-specific re-exports.
pub use MemoryItem;
pub use ;
pub use ;
pub use ;
pub use MetricsSnapshot;
pub use ;
pub use LlmProvider;