pub struct AgentLoopConfig {
pub max_iterations: usize,
pub enable_tools: bool,
pub require_approval: bool,
pub prompt_injection_protection: bool,
pub token_lifetime_secs: u64,
pub no_final_required: bool,
pub fallback_chain: Option<Arc<Mutex<ProviderFallbackChain>>>,
pub token_budget: Option<Arc<Mutex<TokenBudget>>>,
pub ravenfabric: Option<RavenFabricClient>,
pub checkpoint_dir: Option<PathBuf>,
pub session_id: Option<String>,
pub metrics_callback: Option<Box<dyn Fn(u64, u64) + Send + Sync>>,
}Expand description
Agent loop configuration
Note: Debug and Clone are implemented manually because metrics_callback
is a boxed closure that doesn’t implement either trait.
Fields§
§max_iterations: usizeMaximum iterations before forcing completion
enable_tools: boolWhether to enable tool calling
require_approval: boolRequire human approval for tool calls
prompt_injection_protection: boolEnable prompt-injection defense on LLM responses
token_lifetime_secs: u64Maximum session lifetime in seconds (0 = unlimited) When non-zero, the agent loop will stop after this duration to enforce credential/session expiry.
no_final_required: boolWhen true, treat any non-tool-call response as completion (no FINAL: required)
fallback_chain: Option<Arc<Mutex<ProviderFallbackChain>>>Optional provider fallback chain — tries providers in order on failure
token_budget: Option<Arc<Mutex<TokenBudget>>>Optional token budget — limits total tokens used per session
ravenfabric: Option<RavenFabricClient>Optional RavenFabric client — reports agent status and results to mesh
checkpoint_dir: Option<PathBuf>Optional checkpoint directory for durable execution. When set, the agent loop saves state after each iteration and can resume from the latest checkpoint if interrupted.
session_id: Option<String>Unique session ID for checkpointing. If not set but checkpoint_dir is set, a UUID is generated automatically.
metrics_callback: Option<Box<dyn Fn(u64, u64) + Send + Sync>>Optional callback for recording metrics (token usage, tool calls). Called with (tokens_used, tool_calls_count) after each iteration. This allows the HTTP server to wire ServerMetrics without coupling agent.rs to server.rs.
Trait Implementations§
Source§impl Clone for AgentLoopConfig
impl Clone for AgentLoopConfig
Source§impl Debug for AgentLoopConfig
impl Debug for AgentLoopConfig
Auto Trait Implementations§
impl !RefUnwindSafe for AgentLoopConfig
impl !UnwindSafe for AgentLoopConfig
impl Freeze for AgentLoopConfig
impl Send for AgentLoopConfig
impl Sync for AgentLoopConfig
impl Unpin for AgentLoopConfig
impl UnsafeUnpin for AgentLoopConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request