pub struct ToolExecution {
pub tool_call_id: String,
pub thread_id: ThreadId,
pub tool_name: String,
pub display_name: String,
pub input: Value,
pub status: ExecutionStatus,
pub result: Option<ToolResult>,
pub operation_id: Option<String>,
pub started_at: OffsetDateTime,
pub completed_at: Option<OffsetDateTime>,
}Expand description
Record of a tool execution for idempotency.
This struct tracks tool executions to prevent duplicate execution when the agent loop retries after a failure. The write-ahead pattern ensures that execution intent is recorded BEFORE calling the tool, and updated with results AFTER completion.
Fields§
§tool_call_id: StringThe tool call ID from the LLM (unique per invocation)
thread_id: ThreadIdThread this execution belongs to
tool_name: StringTool name
display_name: StringDisplay name
input: ValueInput parameters (for verification)
status: ExecutionStatusCurrent status
result: Option<ToolResult>Result if completed
operation_id: Option<String>For async tools: the operation ID returned by execute()
started_at: OffsetDateTimeTimestamp when execution started
completed_at: Option<OffsetDateTime>Timestamp when execution completed
Implementations§
Source§impl ToolExecution
impl ToolExecution
Sourcepub fn new_in_flight(
tool_call_id: impl Into<String>,
thread_id: ThreadId,
tool_name: impl Into<String>,
display_name: impl Into<String>,
input: Value,
started_at: OffsetDateTime,
) -> Self
pub fn new_in_flight( tool_call_id: impl Into<String>, thread_id: ThreadId, tool_name: impl Into<String>, display_name: impl Into<String>, input: Value, started_at: OffsetDateTime, ) -> Self
Create a new in-flight execution record.
Sourcepub fn complete(&mut self, result: ToolResult)
pub fn complete(&mut self, result: ToolResult)
Mark this execution as completed with a result.
Sourcepub fn set_operation_id(&mut self, operation_id: impl Into<String>)
pub fn set_operation_id(&mut self, operation_id: impl Into<String>)
Set the operation ID for async tool tracking.
Sourcepub fn is_in_flight(&self) -> bool
pub fn is_in_flight(&self) -> bool
Returns true if this execution is still in flight.
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Returns true if this execution has completed.
Trait Implementations§
Source§impl Clone for ToolExecution
impl Clone for ToolExecution
Source§fn clone(&self) -> ToolExecution
fn clone(&self) -> ToolExecution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more