pub struct AgentToolResult {
pub success: bool,
pub output: String,
pub metadata: Option<Value>,
pub content_blocks: Option<Vec<ContentBlock>>,
pub terminate: bool,
pub intent: Option<String>,
}Expand description
Fields§
§success: boolpub.
output: Stringpub.
metadata: Option<Value>pub.
content_blocks: Option<Vec<ContentBlock>>Optional content blocks (e.g., image blocks) to include in the tool result message.
When present, these are used as the content of the ToolResultMessage instead of
wrapping output in a Text block.
terminate: boolWhen true, signals that the agent loop should terminate after this batch
of tool calls completes. Defaults to false so that the loop continues
unless a tool explicitly opts-in to termination.
intent: Option<String>Intent trace — a concise description of what this specific tool call did.
Set by the agent loop from the tool’s static intent() or by the tool
itself for dynamic intent. Included in ToolExecutionEnd events.
Implementations§
Source§impl AgentToolResult
impl AgentToolResult
Sourcepub fn success(output: impl Into<String>) -> AgentToolResult
pub fn success(output: impl Into<String>) -> AgentToolResult
Creates a successful tool result with the given output text.
Sourcepub fn error(output: impl Into<String>) -> AgentToolResult
pub fn error(output: impl Into<String>) -> AgentToolResult
Creates an error tool result with the given error message.
Sourcepub fn with_metadata(self, metadata: Value) -> AgentToolResult
pub fn with_metadata(self, metadata: Value) -> AgentToolResult
Attaches structured metadata (JSON) to this result.
Sourcepub fn with_content_blocks(self, blocks: Vec<ContentBlock>) -> AgentToolResult
pub fn with_content_blocks(self, blocks: Vec<ContentBlock>) -> AgentToolResult
Attaches rich content blocks (images, code, etc.) to this result.
Sourcepub fn with_terminate(self) -> AgentToolResult
pub fn with_terminate(self) -> AgentToolResult
Mark this result as requesting agent-loop termination.
Sourcepub fn with_intent(self, intent: impl Into<String>) -> AgentToolResult
pub fn with_intent(self, intent: impl Into<String>) -> AgentToolResult
Attach an intent trace to this result.