View Source Agens.Serving.Result (agens v0.2.0)

The structured result returned from a Serving's Agens.Serving.handle_result/3 (or Agens.Serving.handle_sub/3) callback.

A Result describes the LM-facing response body, the parsed structured outputs, any tool calls requested by the LM, and the list of routing instructions for the next Node(s).

Fields

  • :body - The main response body string. Required.
  • :outputs - Map of structured output values keyed by Agens.Router.Output.key.
  • :tool_calls - List of tool call requests emitted by the LM.
  • :next - List of route instructions ({:route, node_id, count}, {:yield, node_id}, {:sub, job_id}, :end, :retry, or {:retry, reason}). When empty, the parent Serving's Router runs route/1 against the outputs to produce a fallback list.

Summary

Types

Repetition count for a :route instruction (used to fan out to multiple threads).

Identifier of a target Sub-Job for :sub instructions.

A single routing instruction.

Identifier of a target Node for :route / :yield instructions.

t()

Types

@type count() :: integer()

Repetition count for a :route instruction (used to fan out to multiple threads).

@type job_id() :: binary()

Identifier of a target Sub-Job for :sub instructions.

@type next() ::
  {:route, node_id(), count()}
  | {:yield, node_id()}
  | {:sub, job_id()}
  | :end
  | :retry
  | {:retry, String.t()}

A single routing instruction.

@type node_id() :: binary()

Identifier of a target Node for :route / :yield instructions.

@type t() :: %Agens.Serving.Result{
  body: String.t(),
  next: [next()],
  outputs: map(),
  tool_calls: list()
}