Skip to main content

lc_agents/
lib.rs

1#![warn(missing_docs)]
2// lc-agents/src/lib.rs
3//! Agent system for building autonomous LLM applications.
4//!
5//! Provides core abstractions and implementations for agents.
6//!
7//! # Core Concepts
8//!
9//! - **Agent**: Responsible for planning, deciding what action to execute next.
10//! - **AgentExecutor**: Responsible for execution loop (plan -> act -> observe).
11//! - **Tool**: Callable tools that agents can invoke.
12//!
13//! # Execution Flow
14//!
15//! ```text
16//! Input question
17//!     |
18//! Agent.plan() -> AgentAction or AgentFinish
19//!     |
20//! If Action: execute tool -> get observation
21//!     |
22//! Add to intermediate_steps
23//!     |
24//! Loop until AgentFinish returned
25//! ```
26
27pub mod adapter;
28pub mod adaptive_rag;
29/// Approval gate (§4.2): asynchronous approval gate before tool execution.
30/// Implement [`ApprovalHandler`] and inject it via [`AgentExecutor::with_approval`];
31/// off by default.
32pub mod approval;
33pub mod executor;
34/// Module alias preserving the historical `lc_agents::base` path.
35pub use executor as base;
36pub mod builder;
37pub mod cache;
38pub mod crag;
39pub mod deep_research;
40/// Function calling based agent module.
41pub mod function_calling;
42pub mod handoffs;
43pub mod hooks;
44pub mod metrics;
45pub mod orchestrator;
46/// Module alias preserving the historical `lc_agents::orchestration` path.
47pub use orchestrator as orchestration;
48pub mod plan_execute;
49pub mod policy;
50pub mod react;
51/// Cross-process resume (§4.2 approval/budget gate): suspend-state persistence +
52/// recovery. The framework writes/clears checkpoints ([`ResumeStore`]) around
53/// approvals; a new process inspects via [`AgentExecutor::pending_approval`] and
54/// resumes via [`AgentExecutor::resume`]. Off by default (no [`ResumeStore`] ⇒ no
55/// serialization; existing behavior unchanged).
56pub mod resume;
57pub mod retry;
58pub mod streaming;
59mod structured;
60pub mod task;
61pub mod types;
62
63pub use adapter::{AgentEventRunnable, AgentRunnable, OrchestratorRunnable};
64pub use adaptive_rag::{AdaptiveRAG, AdaptiveRAGError, AdaptiveRAGResult, RagDecision};
65pub use approval::{AllowAll, ApprovalDecision, ApprovalHandler};
66pub use builder::AgentBuilder;
67pub use cache::{MemoryCache, ResponseCache};
68pub use crag::{CRAGError, CRAGResult, CorrectiveRAGAgent};
69pub use deep_research::{Citation, DeepResearchAgent, ResearchError, ResearchReport};
70pub use executor::{
71    estimate_step_tokens, AgentError, AgentExecutor, BaseAgent, BudgetConfig, BudgetExceeded,
72    CompactionConfig, CompactionStrategy, CompactionTrigger,
73};
74pub use function_calling::FunctionCallingAgent;
75pub use handoffs::HandoffManager;
76pub use hooks::{
77    AgentHook, ApprovalHook, CompletionAction, CompletionContext, CompletionResult,
78    ContentFilterHook, ErrorAction, HookError, LoggingHook, PromptInjectionHook, StreamAction,
79    TokenBudgetHook, ToolCallAction, ToolCallContext, ToolResultContext,
80};
81pub use metrics::AgentMetrics;
82pub use orchestrator::{
83    parse_review_verdict, review_envelope, task_adapter, FanOutFanIn, Orchestrator,
84    ReviewOrchestrator, ReviewVerdict, RunContext, SequentialPipeline, TaskAdapter,
85};
86pub use plan_execute::{PlanExecuteAgent, PlanExecuteError};
87pub use policy::{ToolPolicy, ToolRisk};
88pub use react::ReActAgent;
89pub use resume::{FileResumeStore, MemoryResumeStore, PendingApproval, ResumeError, ResumeStore};
90pub use retry::RetryConfig;
91pub use streaming::{AgentStreamEvent, StreamingFunctionCallingAgent, ToolCallState};
92pub use task::AgentTask;
93pub use types::{AgentAction, AgentFinish, AgentOutput, AgentStep, ToolInput};