pub struct ToolResult {
pub output: String,
pub media: Vec<Attachment>,
pub is_error: bool,
}Expand description
Result of a tool execution returned to the LLM.
Use ToolResult::success for normal output and ToolResult::error
for recoverable errors the LLM should see.
Fields§
§output: StringOutput text returned to the LLM.
media: Vec<Attachment>Structured media attachments produced by this tool.
Attachments are delivered by Cortex transports independently from the text the model sees, so tools do not need transport-specific protocols.
is_error: boolWhether this result represents an error condition.
When true, the LLM sees this as a failed tool call and may retry
with different parameters or switch strategy.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn error(output: impl Into<String>) -> Self
pub fn error(output: impl Into<String>) -> Self
Create an error result (tool ran but failed).
Use this for recoverable errors — the LLM sees the output and can decide how to proceed. For example: “file not found”, “permission denied”, “rate limit exceeded”.
Sourcepub fn with_media(self, attachment: Attachment) -> Self
pub fn with_media(self, attachment: Attachment) -> Self
Attach one media item to the result.
Sourcepub fn with_media_many(
self,
media: impl IntoIterator<Item = Attachment>,
) -> Self
pub fn with_media_many( self, media: impl IntoIterator<Item = Attachment>, ) -> Self
Attach multiple media items to the result.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more