pub enum ToolLoopEvent {
IterationStart {
iteration: u32,
message_count: usize,
},
ToolExecutionStart {
call_id: String,
tool_name: String,
arguments: Value,
},
ToolExecutionEnd {
call_id: String,
tool_name: String,
result: ToolResult,
duration: Duration,
},
LlmResponseReceived {
iteration: u32,
has_tool_calls: bool,
text_length: usize,
},
LoopDetected {
tool_name: String,
consecutive_count: u32,
action: LoopAction,
},
}Expand description
Events emitted during tool loop execution for observability.
These events allow UIs to show real-time progress:
- “Iteration 3 starting”
- “Calling tool
search…” - “Tool
searchcompleted in 200ms”
§Example
use llm_stack::tool::{ToolLoopConfig, ToolLoopEvent};
use std::sync::Arc;
let config = ToolLoopConfig {
on_event: Some(Arc::new(|event| {
match event {
ToolLoopEvent::IterationStart { iteration, .. } => {
println!("Starting iteration {iteration}");
}
ToolLoopEvent::ToolExecutionStart { tool_name, .. } => {
println!("Calling {tool_name}...");
}
ToolLoopEvent::ToolExecutionEnd { tool_name, duration, .. } => {
println!("{tool_name} completed in {duration:?}");
}
_ => {}
}
})),
..Default::default()
};Variants§
IterationStart
A new iteration of the tool loop is starting.
Fields
ToolExecutionStart
About to execute a tool.
Fields
ToolExecutionEnd
Tool execution completed.
Fields
§
result: ToolResultThe result from the tool.
LlmResponseReceived
LLM response received for this iteration.
Fields
LoopDetected
A tool call loop was detected.
Emitted when the same tool is called with identical arguments
for threshold consecutive times. Only emitted when
LoopDetectionConfig is configured.
Trait Implementations§
Source§impl Clone for ToolLoopEvent
impl Clone for ToolLoopEvent
Source§fn clone(&self) -> ToolLoopEvent
fn clone(&self) -> ToolLoopEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ToolLoopEvent
impl RefUnwindSafe for ToolLoopEvent
impl Send for ToolLoopEvent
impl Sync for ToolLoopEvent
impl Unpin for ToolLoopEvent
impl UnwindSafe for ToolLoopEvent
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
Mutably borrows from an owned value. Read more