pub struct ToolResult {
pub success: bool,
pub output: Option<String>,
pub error: Option<String>,
pub metadata: HashMap<String, Value>,
pub duration_ms: Option<u64>,
pub llm_suffix: Option<String>,
}Expand description
Result of a tool execution.
Fields§
§success: boolWhether the tool executed successfully.
output: Option<String>Tool output text (for successful results).
error: Option<String>Error message (for failed results).
metadata: HashMap<String, Value>Additional metadata (tool-specific).
duration_ms: Option<u64>Execution duration in milliseconds (populated by the registry).
llm_suffix: Option<String>Hidden suffix appended to the tool result for the LLM but not shown in the UI. Used to silently guide LLM behavior on errors (e.g., retry hints).
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn ok_with_metadata(
output: impl Into<String>,
metadata: HashMap<String, Value>,
) -> Self
pub fn ok_with_metadata( output: impl Into<String>, metadata: HashMap<String, Value>, ) -> Self
Create a successful result with metadata.
Sourcepub fn with_llm_suffix(self, suffix: impl Into<String>) -> Self
pub fn with_llm_suffix(self, suffix: impl Into<String>) -> Self
Attach an LLM-only suffix to this result.
Sourcepub fn from_error(err: ToolError) -> Self
pub fn from_error(err: ToolError) -> Self
Create a result from a ToolError.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolResult
impl Debug for ToolResult
Source§impl<'de> Deserialize<'de> for ToolResult
impl<'de> Deserialize<'de> for ToolResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin for ToolResult
impl UnwindSafe for ToolResult
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