The public state passed to all Omni.Agent callbacks.
Internal server machinery (task tracking, tool decision state, process refs) is managed separately and not exposed to callbacks.
Fields fall into two groups:
Configuration — set at startup, changeable via set_state/2,3:
:model— the%Model{}this agent is using:system— system prompt string, ornil:messages— committed message history. Only changes at turn boundaries or viaset_state(:messages, ...); in-progress turn messages are held internally until the turn completes:tools— list of%Tool{}available to the model:opts— agent-level default inference options (keyword list), passed tostream_texteach step
Runtime — change during operation:
:private— runtime state (PIDs, ETS refs, closures). Not persisted. Set initial values via the:privatestart option or ininit/1, update in any callback via%{state | private: ...}. Not settable viaset_state/2,3. The:omnikey is reserved — when running underOmni.Session, the session writesprivate[:omni] = %{session_id: ..., session_pid: ...}beforeinit/1runs and overwrites any user-supplied value. Use any other key freely:status—:idle,:busy, or:paused:step— current step counter within the active turn. Resets to0when a new turn begins. Useful for step-based policies in callbacks (e.g. rejecting tools after a threshold)
Summary
Functions
Validates that a message list is safe to sit idle in state.messages.
Types
@type t() :: %Omni.Agent.State{ messages: [Omni.Message.t()], model: Omni.Model.t(), opts: keyword(), private: map(), status: :idle | :busy | :paused, step: non_neg_integer(), system: String.t() | nil, tools: [Omni.Tool.t()] }
The public agent state passed to all callbacks.
Functions
@spec validate_messages([Omni.Message.t()]) :: :ok | {:error, :invalid_messages}
Validates that a message list is safe to sit idle in state.messages.
Returns :ok if the list is empty, or if its last message has
role: :assistant and contains no %Omni.Content.ToolUse{} blocks.
Otherwise returns {:error, :invalid_messages}.
This is the invariant enforced at set_state(:messages, ...) and on the
state returned from init/1. It does not perform deep validation of
interior messages.