pub struct ToolResultPart {
pub call_id: ToolCallId,
pub output: ToolOutput,
pub is_error: bool,
pub metadata: MetadataMap,
}Expand description
The result of executing a tool, sent back to the model.
Each ToolResultPart references the ToolCallPart it answers via
call_id. The is_error flag tells the model whether the tool succeeded.
§Example
use agentkit_core::{ToolOutput, ToolResultPart};
let result = ToolResultPart::success("call-7", ToolOutput::text("fn main() { ... }"));
assert!(!result.is_error);Fields§
§call_id: ToolCallIdThe ToolCallId of the tool call this result answers.
output: ToolOutputThe output produced by the tool.
is_error: booltrue if the tool execution failed.
metadata: MetadataMapArbitrary key-value metadata.
Implementations§
Source§impl ToolResultPart
impl ToolResultPart
Sourcepub fn success(call_id: impl Into<ToolCallId>, output: ToolOutput) -> Self
pub fn success(call_id: impl Into<ToolCallId>, output: ToolOutput) -> Self
Builds a successful tool-result part with empty metadata.
Sourcepub fn error(call_id: impl Into<ToolCallId>, output: ToolOutput) -> Self
pub fn error(call_id: impl Into<ToolCallId>, output: ToolOutput) -> Self
Builds an error tool-result part with empty metadata.
Sourcepub fn with_is_error(self, is_error: bool) -> Self
pub fn with_is_error(self, is_error: bool) -> Self
Sets the error flag explicitly.
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Replaces the tool-result metadata.
Trait Implementations§
Source§impl Clone for ToolResultPart
impl Clone for ToolResultPart
Source§fn clone(&self) -> ToolResultPart
fn clone(&self) -> ToolResultPart
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 ToolResultPart
impl Debug for ToolResultPart
Source§impl<'de> Deserialize<'de> for ToolResultPart
impl<'de> Deserialize<'de> for ToolResultPart
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 ToolResultPart
impl PartialEq for ToolResultPart
Source§impl Serialize for ToolResultPart
impl Serialize for ToolResultPart
impl StructuralPartialEq for ToolResultPart
Auto Trait Implementations§
impl Freeze for ToolResultPart
impl RefUnwindSafe for ToolResultPart
impl Send for ToolResultPart
impl Sync for ToolResultPart
impl Unpin for ToolResultPart
impl UnsafeUnpin for ToolResultPart
impl UnwindSafe for ToolResultPart
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