Agentic.LLM.Response (agentic v0.2.2)

Copy Markdown

Normalized chat response shape produced by every transport.

Fields

  • :content — list of content blocks. Each block is a map of one of:
    • %{type: :text, text: String.t()}
    • %{type: :tool_use, id: String.t(), name: String.t(), input: map()}
  • :stop_reason — one of :end_turn | :tool_use | :max_tokens | :error

  • :usage%{input_tokens, output_tokens, cache_read, cache_write} (cache fields default to 0)
  • :cost — computed USD cost for this call (set by LLMCall stage)
  • :model_id — provider-local model id (when known)
  • :raw — the unmodified decoded response body, kept for debugging

Transports translate their wire format into this shape. The host application and all loop stages consume this struct directly.

Summary

Types

content_block()

@type content_block() ::
  %{type: :text, text: String.t()}
  | %{type: :tool_use, id: String.t(), name: String.t(), input: map()}

stop_reason()

@type stop_reason() :: :end_turn | :tool_use | :max_tokens | :error

t()

@type t() :: %Agentic.LLM.Response{
  content: [content_block()],
  cost: float(),
  model_id: String.t() | nil,
  raw: term(),
  stop_reason: stop_reason(),
  usage: usage()
}

usage()

@type usage() :: %{
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer(),
  cache_read: non_neg_integer(),
  cache_write: non_neg_integer()
}