ExAgent.Message.Part.ToolReturn (ExAgent v3.0.0)

View Source

The return value of a tool call, fed back to the model.

Stability — Stable.

usage is an optional contributed token usage (e.g. from a delegated sub-agent run) that the agent loop merges into the run's accumulated usage. It is nil for ordinary tools and is not part of the serialized message history (usage is accounted for at runtime).

payload_omitted distinguishes an omitted value from a genuine nil result. A genuine nil is serialized as JSON null. A literal string such as "nil" stays a string when the history is loaded. Booleans retain their JSON type. Other atom results are stored as their name. Status describes the effect even when its payload was omitted. Such history is diagnostic and cannot be executed as ordinary model context.

content_withheld marks a receipt whose content was withheld pending tool-output approval or after a veto. The status still describes the effect.

Summary

Types

status()

@type status() ::
  :succeeded
  | :deferred
  | :tool_error
  | :validation_error
  | :denied
  | :failed
  | :unknown
  | :not_executed

t()

@type t() :: %ExAgent.Message.Part.ToolReturn{
  content: term(),
  content_withheld: boolean(),
  payload_omitted: term(),
  status: status(),
  tool_call_id: String.t(),
  tool_name: String.t(),
  usage: ExAgent.Message.Usage.t() | nil
}