Jido.Chat.Content.ToolResult (Jido Chat v1.0.0)

Copy Markdown View Source

Tool result content block for messages.

Represents the result of a tool/action invocation. This maps to the LLM's tool_result blocks and contains the output from jido_action execution.

Fields

  • tool_use_id - The ID of the ToolUse this result corresponds to
  • content - The result content (can be text, structured data, or error info)
  • is_error - Whether this result represents an error

Example

ToolResult.new("call_123", "The weather in San Francisco is 72°F")
#=> %ToolResult{type: :tool_result, tool_use_id: "call_123", content: "The weather...", is_error: false}

ToolResult.new("call_456", "Tool not found: unknown_tool", true)
#=> %ToolResult{type: :tool_result, tool_use_id: "call_456", content: "Tool not found...", is_error: true}

Summary

Functions

Creates a new tool result content block.

Returns the Zoi schema for ToolResult content

Types

t()

@type t() :: %Jido.Chat.Content.ToolResult{
  content: any(),
  is_error: boolean(),
  tool_use_id: binary(),
  type: :tool_result
}

Functions

new(tool_use_id, content, is_error \\ false)

Creates a new tool result content block.

Parameters

  • tool_use_id - The ID of the ToolUse this result corresponds to
  • content - The result content (string, map, or any term)
  • is_error - Whether this result represents an error (default: false)

Examples

iex> ToolResult.new("call_1", %{results: [1, 2, 3]})
%ToolResult{type: :tool_result, tool_use_id: "call_1", content: %{results: [1, 2, 3]}, is_error: false}

iex> ToolResult.new("call_2", "Error: timeout", true)
%ToolResult{type: :tool_result, tool_use_id: "call_2", content: "Error: timeout", is_error: true}

schema()

Returns the Zoi schema for ToolResult content