Expand description
§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
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] (providersfeature) — plug in any LLM API. CircuitBreakerBackend(redis-circuit-breakerfeature) — 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)
Re-exports§
pub use error::AgentRuntimeError;pub use runtime::AgentRuntime;pub use runtime::AgentRuntimeBuilder;pub use runtime::AgentSession;pub use types::AgentId;pub use types::MemoryId;pub use memory::MemoryItem;pub use graph::Entity;pub use graph::EntityId;pub use graph::GraphStore;pub use graph::Relationship;pub use orchestrator::CircuitBreaker;pub use orchestrator::Pipeline;pub use orchestrator::RetryKind;pub use orchestrator::RetryPolicy;pub use agent::Action;pub use agent::AgentConfig;pub use agent::ReActLoop;pub use agent::ReActStep;pub use agent::ToolSpec;pub use agent::ToolValidator;pub use metrics::MetricsSnapshot;
Modules§
- agent
- Module: Agent
- error
- Unified error type for the agent-runtime crate.
- graph
- Module: Graph
- memory
- Module: Memory
- metrics
- Module: Metrics
- orchestrator
- Module: Orchestrator
- prelude
- Convenience re-exports for the most commonly used types.
- runtime
- Module: AgentRuntime
- types
- Core identifier types, available without feature gates.
- util
- Shared utility functions used across modules.