pub struct ToolResultBlock { /* private fields */ }Expand description
Tool execution result sent back to the model.
After executing a tool requested via ToolUseBlock, the application
creates a ToolResultBlock containing the tool’s output and sends it back
to the model. The model then uses this information in its next response.
§Fields
tool_use_id: Must match theidfrom the corresponding ToolUseBlockcontent: JSON result from the tool execution
§Example
use open_agent::{ToolResultBlock, ContentBlock};
use serde_json::json;
let result = ToolResultBlock::new(
"call_123",
json!({"result": 4})
);
assert_eq!(result.tool_use_id(), "call_123");Implementations§
Source§impl ToolResultBlock
impl ToolResultBlock
Sourcepub fn new(tool_use_id: impl Into<String>, content: Value) -> Self
pub fn new(tool_use_id: impl Into<String>, content: Value) -> Self
Creates a new tool result block.
§Parameters
tool_use_id: ID from the corresponding ToolUseBlockcontent: JSON result from tool execution
§Example
use open_agent::ToolResultBlock;
use serde_json::json;
let result = ToolResultBlock::new(
"call_xyz",
json!({
"status": "success",
"data": {"temperature": 72}
})
);Sourcepub fn tool_use_id(&self) -> &str
pub fn tool_use_id(&self) -> &str
Returns the ID of the tool use request this result corresponds to.
Trait Implementations§
Source§impl Clone for ToolResultBlock
impl Clone for ToolResultBlock
Source§fn clone(&self) -> ToolResultBlock
fn clone(&self) -> ToolResultBlock
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 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<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 ToolResultBlock
impl RefUnwindSafe for ToolResultBlock
impl Send for ToolResultBlock
impl Sync for ToolResultBlock
impl Unpin for ToolResultBlock
impl UnwindSafe 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