Jido.AgentServer.State
(Jido v2.0.0-rc.4)
View Source
Internal state for AgentServer GenServer.
Internal Module
This module is internal to the AgentServer implementation. Its API may
change without notice. Use Jido.AgentServer.state/1 to retrieve state.
This struct holds all runtime state for an agent instance including the agent itself, directive queue, hierarchy tracking, and configuration.
Summary
Functions
Adds a child to the children map.
Dequeues the next directive for processing.
Enqueues a directive with its triggering signal for later execution.
Enqueues multiple directives from a single signal.
Creates a new State from validated Options, agent module, and agent struct.
Gets a child by tag.
Returns recent debug events, newest first.
Increments the error count.
Checks if the queue is empty.
Returns the current queue length.
Records a debug event if debug mode is enabled.
Removes a child by tag.
Removes a child by PID.
Enables or disables debug mode at runtime.
Sets the status.
Updates the agent in state.
Types
@type status() :: :initializing | :idle | :processing | :stopping
@type t() :: %Jido.AgentServer.State{ agent: any(), agent_module: atom(), children: map(), completion_waiters: map(), cron_jobs: map(), debug: boolean(), debug_events: [any()], default_dispatch: any(), error_count: integer(), error_policy: any(), id: binary(), jido: atom(), lifecycle: any(), max_queue_size: integer(), metrics: map(), on_parent_death: atom(), parent: any(), processing: boolean(), queue: any(), registry: atom(), signal_router: any(), skip_schedules: boolean(), spawn_fun: any(), status: atom() }
Functions
@spec add_child(t(), term(), Jido.AgentServer.ChildInfo.t()) :: t()
Adds a child to the children map.
@spec dequeue(t()) :: {{:value, {Jido.Signal.t(), struct()}}, t()} | {:empty, t()}
Dequeues the next directive for processing.
@spec enqueue(t(), Jido.Signal.t(), struct()) :: {:ok, t()} | {:error, :queue_overflow}
Enqueues a directive with its triggering signal for later execution.
@spec enqueue_all(t(), Jido.Signal.t(), [struct()]) :: {:ok, t()} | {:error, :queue_overflow}
Enqueues multiple directives from a single signal.
@spec from_options(Jido.AgentServer.Options.t(), module(), struct()) :: {:ok, t()} | {:error, term()}
Creates a new State from validated Options, agent module, and agent struct.
If a parent reference is provided, it's injected into the agent's state
as agent.state.__parent__ so agents can use Directive.emit_to_parent/3.
@spec get_child(t(), term()) :: Jido.AgentServer.ChildInfo.t() | nil
Gets a child by tag.
Returns recent debug events, newest first.
Options
:limit- Maximum number of events to return (default: all)
Increments the error count.
Checks if the queue is empty.
@spec queue_length(t()) :: non_neg_integer()
Returns the current queue length.
Records a debug event if debug mode is enabled.
Events are stored in a ring buffer (max 50 entries). Each event includes a monotonic timestamp for relative timing.
Removes a child by tag.
Removes a child by PID.
Enables or disables debug mode at runtime.
Sets the status.
Updates the agent in state.