# `ReqLLM.ToolResult`
[🔗](https://github.com/agentjido/req_llm/blob/main/lib/req_llm/tool_result.ex#L1)

ToolResult represents structured and multi-part tool outputs while keeping
application-visible data separate from model-facing content.

* `output` is the original application value. Maps and lists remain available
  to local code and provider adapters without a text round trip.
* `content` is the content sent back to the model. It may contain text or
  `ReqLLM.Message.ContentPart` values for images and files. When omitted,
  `ReqLLM.Context` derives model-facing text from `output`.
* `metadata` carries supplementary application or provider-native data. It is
  not a substitute for model-facing error or result content.

These fields may intentionally differ. For example, an application can keep a
rich JSON result in `output` while returning a concise explanation, an error,
or a multimodal file/image payload in `content`:

    %ReqLLM.ToolResult{
      output: %{document_id: "doc_123", page_count: 4},
      content: [
        ReqLLM.Message.ContentPart.text("The requested document is attached."),
        ReqLLM.Message.ContentPart.file_id("file_123")
      ],
      metadata: %{provider_native: %{request_id: "req_123"}}
    }

Tool callbacks retain their existing contract: return `{:ok, result}` for a
successful result or `{:error, result}` for an error. Either result may be a
plain text/JSON value or a `ToolResult`.

# `t`

```elixir
@type t() :: %ReqLLM.ToolResult{
  content: nil | [any()],
  metadata: map(),
  output: nil | any()
}
```

# `explicit_content?`

```elixir
@spec explicit_content?(ReqLLM.Message.t() | map()) :: boolean()
```

Returns whether a normalized tool message contains explicitly supplied result content.

# `metadata_key`

```elixir
@spec metadata_key() :: atom()
```

# `output_from_message`

```elixir
@spec output_from_message(ReqLLM.Message.t() | map()) :: term() | nil
```

# `put_message_metadata`

```elixir
@spec put_message_metadata(map(), t()) :: map()
```

Preserves a tool result's output and explicit-content provenance in message metadata.

# `put_output_metadata`

```elixir
@spec put_output_metadata(map(), term() | nil) :: map()
```

# `schema`

Returns the Zoi schema for this module

---

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