ExAgent. ModelRequest
(ExAgent v3.0.0)
View Source
The model request that capability hooks see and transform.
Stability — Stable.
ExAgent.Capability.before_model_request/3 receives one for every request
the run is about to send and returns it, possibly changed. Four fields are
writable:
:messages— the projection sent to the model. It starts as the canonical history with the agent's instruction functions and then the capabilities'instructions/2inserted after the first request's own instructions. An opt-inExAgent.Memory.capability/2can add data to the current user turn. Changing the projection never changes the history,new_messagesor a later request.:tools— the function tools selected for this request. It starts as the whole:inventory, in order, for every request: a selection never carries over to the next one. A hook may drop and reorder tools, but every tool must be one of the:inventorystructs; any other value fails the run before IO with{:capability_failed, module, :before_model_request, {:unknown_tool, name}}. Only the selected tools are executable for that request. InExAgent.Tool.Searchbridge mode, the final selection can include deferred tools callable through the bridge. The runtime omits their declarations from the provider request after the hooks run.:settings— theExAgent.ModelSettingsfor this request. It starts as the run's settings for every request and must be a struct thatExAgent.ModelSettings.new/1would build; any other value fails the run before IO with{:invalid_field, :settings}.:model— the model struct that handles this request. Unlike the other writable fields, a change carries over: the struct holds the model's own state (a scripted position, a fallback candidate, a continuation binding), so the next request starts from the model this one used.
The other fields are read-only: :history (the canonical history),
:inventory (every function tool of the agent, resolved by ExAgent.new/1),
:output (%{mode, tools, object}), :step and :final_step. A hook that
changes one fails the run with
{:capability_failed, module, hook, {:read_only, field}}. Budgets, retry
counters and other runtime state are not part of the request.
Summary
Types
@type output() :: %{ mode: :text | :tool | :native | :prompted, tools: [ExAgent.Tool.t()], object: ExAgent.ModelRequestParameters.output_object() | nil }
Structured output of the request: its mode, output tools and schema. With
:prompted the schema instruction is already in :messages, and the model
receives the request as :text.
@type t() :: %ExAgent.ModelRequest{ final_step: boolean(), history: [ExAgent.Message.t()], inventory: [ExAgent.Tool.t()], messages: [ExAgent.Message.t()], model: ExAgent.Model.model(), output: output(), settings: ExAgent.ModelSettings.t(), step: pos_integer(), tools: [ExAgent.Tool.t()] }