The result of a completed prompt turn, delivered to GenAgent.handle_response/3.
A Response is built by the state machine after a terminal event
(:result or :error) arrives from the backend. It carries:
:text-- the full assembled assistant text for the turn.:events-- the complete retained event log for a successful turn, in arrival order. A turn exceeding configured capture limits fails with{:event_capture_overflow, diagnostics}instead of returning a response with silently missing events.:usage-- token usage if the backend reported any, otherwisenil.:duration_ms-- wall-clock time from prompt dispatch to terminal event.:session_id-- the backend's session identifier, if any.
Summary
Functions
Build a Response from a completed turn's event list and wall-clock duration.
Types
@type t() :: %GenAgent.Response{ duration_ms: non_neg_integer(), events: [GenAgent.Event.t()], session_id: String.t() | nil, text: String.t(), usage: map() | nil }
Functions
@spec from_events([GenAgent.Event.t()], keyword()) :: t()
Build a Response from a completed turn's event list and wall-clock duration.
The events list must include exactly one terminal event (:result or
:error). Text is taken from the :result event's :text field if
present, otherwise assembled from any :text deltas. Deltas concatenate
directly; a text event with message_boundary: true starts a separate
assistant message after a blank line. Usage is taken from the most recent
:usage event, if any.