A completed assistant turn.
Returned by ExAgent.chat/3 and by ExAgent.collect/1 on a chunk stream, so
streaming and non-streaming share one downstream code path.
{:ok, response} = ExAgent.chat(agent, "Explain OTP")
response.content #=> "OTP is ..."
response.usage.total_tokens #=> 412
response.finish_reason #=> :stop:message holds the ExAgent.Message appended to conversation history;
:content is a shortcut for response.message.content.
:thinking carries a reasoning trace when the model emitted one. It is
deliberately kept out of :message - reasoning is not conversation history,
and replaying it corrupts the next turn.
:structured holds the struct cast from the answer when :schema was given,
and nil otherwise. :content still carries the raw JSON string, so nothing
is lost.
Summary
Functions
Wraps an assistant message in a response.
Types
@type t() :: %ExAgent.Response{ content: String.t(), finish_reason: ExAgent.Chunk.finish_reason(), message: ExAgent.Message.t(), structured: struct() | [struct()] | nil, thinking: String.t() | nil, tool_calls: [map()] | nil, usage: usage() }
@type usage() :: %{ optional(:input_tokens) => non_neg_integer() | nil, optional(:output_tokens) => non_neg_integer() | nil, optional(:total_tokens) => non_neg_integer() | nil }
Functions
@spec new( ExAgent.Message.t(), keyword() ) :: t()
Wraps an assistant message in a response.
Examples
iex> {:ok, message} = ExAgent.Message.new(role: :assistant, content: "hi")
iex> ExAgent.Response.new(message).content
"hi"