pub struct ToolResultBlock {
pub tool_use_id: String,
pub cache_control: Option<CacheControlEphemeral>,
pub content: Option<ToolResultBlockContent>,
pub is_error: Option<bool>,
}anthropic-client only.Expand description
A block containing the result of a tool execution.
ToolResultBlock represents the output from executing a tool that was previously requested via a ToolUseBlock. It contains the tool’s response, which can be either successful output or an error indication.
Fields§
§tool_use_id: StringThe ID of the tool use that this result is for.
This must match the ID from the corresponding ToolUseBlock.
cache_control: Option<CacheControlEphemeral>Create a cache control breakpoint at this content block.
When set, this creates an ephemeral cache point that can be reused in subsequent requests to avoid reprocessing the tool result.
content: Option<ToolResultBlockContent>The content of the tool result, which can be either a string or an array of content items.
This contains the actual output from the tool execution. It can be simple text or structured content including images and formatted text.
is_error: Option<bool>Whether this tool result represents an error.
When true, indicates that the tool execution failed and the content contains error information rather than successful output.
Implementations§
Source§impl ToolResultBlock
impl ToolResultBlock
Sourcepub fn new(tool_use_id: String) -> ToolResultBlock
pub fn new(tool_use_id: String) -> ToolResultBlock
Create a new ToolResultBlock with the given tool use ID.
Sourcepub fn with_cache_control(
self,
cache_control: CacheControlEphemeral,
) -> ToolResultBlock
pub fn with_cache_control( self, cache_control: CacheControlEphemeral, ) -> ToolResultBlock
Add a cache control to this tool result block.
Sourcepub fn with_string_content(self, content: String) -> ToolResultBlock
pub fn with_string_content(self, content: String) -> ToolResultBlock
Add string content to this tool result block.
Sourcepub fn with_array_content(self, content: Vec<Content>) -> ToolResultBlock
pub fn with_array_content(self, content: Vec<Content>) -> ToolResultBlock
Add array content to this tool result block.
Sourcepub fn with_text_content(self, text: TextBlock) -> ToolResultBlock
pub fn with_text_content(self, text: TextBlock) -> ToolResultBlock
Add a single text content item to this tool result block.
Sourcepub fn with_error(self, is_error: bool) -> ToolResultBlock
pub fn with_error(self, is_error: bool) -> ToolResultBlock
Set this tool result block as an error.
Trait Implementations§
Source§impl Clone for ToolResultBlock
impl Clone for ToolResultBlock
Source§fn clone(&self) -> ToolResultBlock
fn clone(&self) -> ToolResultBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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: __D,
) -> Result<ToolResultBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolResultBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<ToolResultBlock> for ContentBlock
impl From<ToolResultBlock> for ContentBlock
Source§fn from(block: ToolResultBlock) -> ContentBlock
fn from(block: ToolResultBlock) -> ContentBlock
Source§impl PartialEq for ToolResultBlock
impl PartialEq for ToolResultBlock
Source§fn eq(&self, other: &ToolResultBlock) -> bool
fn eq(&self, other: &ToolResultBlock) -> bool
self and other values to be equal, and is used by ==.