Skip to main content

temporal_agent_rs/
lib.rs

1//! # temporal-agent-rs
2//!
3//! Durable AI agent execution on top of [Temporal](https://temporal.io) using
4//! [AutoAgents](https://github.com/liquidos-ai/AutoAgents) for the
5//! LLM-provider and tool abstractions.
6//!
7//! ## Pattern
8//!
9//! The library re-implements the ReAct loop inside a Temporal workflow
10//! ([`AgentWorkflow`]). The workflow stays deterministic; every LLM call and
11//! every tool invocation is checkpointed as a separate Temporal activity. A
12//! mid-loop crash resumes from the last completed activity without
13//! re-spending LLM tokens.
14//!
15//! ## Quick start
16//!
17//! ```no_run
18//! use std::sync::Arc;
19//! use temporal_agent_rs::prelude::*;
20//!
21//! # async fn run(client: temporalio_client::Client, llm: Arc<dyn LLMProvider>, tool: Arc<dyn ToolT>) -> anyhow::Result<()> {
22//! let runtime = temporalio_sdk_core::CoreRuntime::new_assume_tokio(Default::default())?;
23//! let mut worker = AgentWorkerBuilder::new(client)
24//!     .llm(llm)
25//!     .tool(tool)
26//!     .queue("agents")
27//!     .build_worker(&runtime)?;
28//! worker.run().await?;
29//! # Ok(())
30//! # }
31//! ```
32//!
33//! See the `math_agent` example for the full client-side flow.
34
35pub mod activities;
36pub mod builder;
37pub mod error;
38pub mod llm;
39pub mod prelude;
40pub mod state;
41pub mod tool;
42pub mod workflow;
43
44pub use crate::activities::AgentActivities;
45pub use crate::builder::AgentWorkerBuilder;
46pub use crate::error::AgentError;
47pub use crate::state::{
48    AgentInput, AgentOutput, AgentState, LlmChatInput, LlmResponse, Message, Role, StopReason,
49    ToolCall, ToolResult, ToolSchema,
50};
51pub use crate::tool::{ToolRegistry, ToolRegistryBuilder};
52pub use crate::workflow::AgentWorkflow;