Carries data through the agentic iteration pipeline.
One Context is created per LLM response and flows through all stages
of the LlmCore.Agent.Pipeline.Iteration pipeline. The outer loop
(LlmCore.Agent.Loop) creates this from the LLM response, sends it
through the pipeline, and reads the decision field to determine the
next action.
Fields
Input — set by the outer loop before pipeline entry
messages— Current message list (grows each iteration)tools— Available tool definitions ([LlmToolkit.Tool.t()])response— The LLM response for this iterationresolve_tool—fn(%Call{}) -> {:ok, String.t()} | {:error, String.t()}resolver_module— Optional module implementingToolResolverbehaviour. When set,DispatchToolschecks for dispatch recipes viaresolver_module.dispatch_recipe/1.iteration— Current iteration count (0-based)max_iterations— Hard iteration limit
Intermediate — populated by pipeline stages
tool_calls— Parsed tool call requests from the responsetool_results— Results after tool executionresult_messages— Formatted messages for the next LLM turnvalidation_errors— Errors from call validation
Output — read by the outer loop after pipeline exit
decision—{:continue, messages},{:done, response}, or{:error, reason}status—:okor:error(short-circuit flag for stages)error— Error detail whenstatus == :errortrace— Accumulated trace entries for observability
Summary
Types
@type decision() :: {:continue, [map()]} | {:done, LlmCore.LLM.Response.t()} | {:error, term()} | nil
@type t() :: %LlmCore.Agent.Context{ decision: decision(), error: term() | nil, iteration: non_neg_integer(), max_iterations: pos_integer(), messages: [map()], resolve_tool: (LlmToolkit.Tool.Call.t() -> {:ok, String.t()} | {:error, String.t()}) | nil, resolver_module: module() | nil, response: LlmCore.LLM.Response.t() | nil, result_messages: [map()], status: :ok | :error, tool_calls: [LlmToolkit.Tool.Call.t()], tool_results: [LlmToolkit.Tool.Result.t()], tools: [LlmToolkit.Tool.t()], trace: [term()], validation_errors: [term()] }