#[non_exhaustive]pub struct ToolResultBlock {
pub tool_use_id: String,
pub status: ToolResultStatus,
pub content: Vec<ToolResultContent>,
pub error: Option<ToolResultError>,
}Expand description
The result of a tool execution (ToolResultBlock).
error is available to hooks and the agent loop but is never serialized. Equality compares
tool_use_id, status and content and ignores error, so a restored result equals the
original.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tool_use_id: StringThe id of the tool use this result answers.
status: ToolResultStatusStatus of the tool execution.
content: Vec<ToolResultContent>The content the tool returned.
error: Option<ToolResultError>The original error when status is ToolResultStatus::Error.
Implementations§
Source§impl ToolResultBlock
impl ToolResultBlock
Sourcepub fn new(
tool_use_id: impl Into<String>,
status: ToolResultStatus,
content: Vec<ToolResultContent>,
) -> Self
pub fn new( tool_use_id: impl Into<String>, status: ToolResultStatus, content: Vec<ToolResultContent>, ) -> Self
Creates a tool result.
Sourcepub fn success(
tool_use_id: impl Into<String>,
content: Vec<ToolResultContent>,
) -> Self
pub fn success( tool_use_id: impl Into<String>, content: Vec<ToolResultContent>, ) -> Self
Creates a successful tool result.
Sourcepub fn error(
tool_use_id: impl Into<String>,
content: Vec<ToolResultContent>,
) -> Self
pub fn error( tool_use_id: impl Into<String>, content: Vec<ToolResultContent>, ) -> Self
Creates a failed tool result.
Sourcepub fn with_error(
self,
error: impl Into<Box<dyn StdError + Send + Sync + 'static>>,
) -> Self
pub fn with_error( self, error: impl Into<Box<dyn StdError + Send + Sync + 'static>>, ) -> Self
Attaches the error that caused the result.
Sourcepub fn with_content(self, content: Vec<ToolResultContent>) -> Self
pub fn with_content(self, content: Vec<ToolResultContent>) -> Self
Replaces the content, keeping the tool use id, status and error (with({ content })).
Trait Implementations§
Source§impl Clone for ToolResultBlock
impl Clone for ToolResultBlock
Source§impl Debug for ToolResultBlock
impl Debug for ToolResultBlock
Source§impl<'de> Deserialize<'de> for ToolResultBlock
impl<'de> Deserialize<'de> for ToolResultBlock
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<ToolResultBlock> for ToolOutcome
impl From<ToolResultBlock> for ToolOutcome
Source§fn from(result: ToolResultBlock) -> Self
fn from(result: ToolResultBlock) -> Self
Converts to this type from the input type.
Source§impl From<ToolResultBlock> for ToolStreamItem
impl From<ToolResultBlock> for ToolStreamItem
Source§fn from(result: ToolResultBlock) -> Self
fn from(result: ToolResultBlock) -> Self
Converts to this type from the input type.
Source§impl From<ToolResultBlock> for ContentBlock
impl From<ToolResultBlock> for ContentBlock
Source§fn from(block: ToolResultBlock) -> Self
fn from(block: ToolResultBlock) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ToolResultBlock
impl PartialEq for ToolResultBlock
Auto Trait Implementations§
impl !RefUnwindSafe for ToolResultBlock
impl !UnwindSafe for ToolResultBlock
impl Freeze for ToolResultBlock
impl Send for ToolResultBlock
impl Sync for ToolResultBlock
impl Unpin for ToolResultBlock
impl UnsafeUnpin for ToolResultBlock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.