pub struct ToolResult {
pub tool_call_id: String,
pub content: String,
pub is_error: bool,
pub error_category: Option<UserErrorCategory>,
}Expand description
Result from executing a tool, sent back to the LLM.
After executing a ToolCall, create a ToolResult to send back.
The LLM will use this information to continue the conversation.
§Example
use multi_llm::ToolResult;
// Successful result
let success = ToolResult {
tool_call_id: "call_abc123".to_string(),
content: "Weather in Paris: Sunny, 18°C".to_string(),
is_error: false,
error_category: None,
};
// Error result
use multi_llm::error::UserErrorCategory;
let error = ToolResult {
tool_call_id: "call_xyz789".to_string(),
content: "City not found".to_string(),
is_error: true,
error_category: Some(UserErrorCategory::NotFound),
};Fields§
§tool_call_id: StringID of the tool call this result responds to.
Must match the id from the corresponding ToolCall.
content: StringResult content from the tool execution.
For successful calls, this is the tool’s output (often a string or JSON). For errors, this should describe what went wrong.
is_error: boolWhether the tool execution failed.
When true, the LLM knows the tool didn’t work and may try alternatives.
error_category: Option<UserErrorCategory>Error category for structured error handling.
Only meaningful when is_error is true. Helps applications handle
different error types appropriately.
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 · 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
Source§impl PartialEq for ToolResult
impl PartialEq for ToolResult
Source§impl Serialize for ToolResult
impl Serialize for ToolResult
impl StructuralPartialEq for ToolResult
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin 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