Omni.Content.ToolResult (Omni v2.0.0)

Copy Markdown View Source

A tool result content block: the output of one tool use.

It goes in a user message, answering an Omni.Content.ToolUse in the assistant message before it. The tool loop builds these for you; build them yourself with Omni.tool_result/1 when you run tools by hand (see Running tools yourself).

Struct fields

  • :tool_use_id - the :id of the tool use this answers
  • :name - the tool's name
  • :content - the result, as Omni.Content.Text and Omni.Content.Attachment blocks. Only some providers take images in a tool result
  • :is_error - true when the tool failed, so the model knows the content describes an error

Summary

Types

Allowed content types within a tool result.

t()

The output of a tool use, linked to it by id.

Functions

Creates a new tool result content block from a keyword list or map.

Types

content()

Allowed content types within a tool result.

t()

@type t() :: %Omni.Content.ToolResult{
  content: [content()],
  is_error: boolean(),
  name: String.t(),
  tool_use_id: String.t()
}

The output of a tool use, linked to it by id.

Functions

new(attrs)

@spec new(Enumerable.t()) :: t()

Creates a new tool result content block from a keyword list or map.

String content is wrapped in an Omni.Content.Text block, and so is each string in a content list. Missing content becomes [].

ToolResult.new(tool_use_id: tool_use.id, name: tool_use.name, content: "72°F and sunny")