# `Omni.Content.ToolResult`
[🔗](https://github.com/aaronrussell/omni/blob/v2.0.0/lib/omni/content/tool_result.ex#L1)

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](text-generation.md#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

# `content`

```elixir
@type content() :: Omni.Content.Text.t() | Omni.Content.Attachment.t()
```

Allowed content types within a tool result.

# `t`

```elixir
@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.

# `new`

```elixir
@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 `[]`.

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
