Jido.AgentServer.Status (Jido v2.0.0-rc.0)

View Source

Runtime status for an agent process.

Combines Strategy.Snapshot with process-level metadata to provide a clean, stable API for querying agent status without depending on internal __strategy__ implementation details.

Fields

  • agent_module - The agent's module (e.g., MyAgent)
  • agent_id - The agent's unique ID
  • pid - The GenServer process PID
  • snapshot - The Strategy.Snapshot containing core status info
  • raw_state - Escape hatch containing full agent state (use sparingly)

Usage

{:ok, agent_status} = AgentServer.status(pid)

# Check if completed
if agent_status.snapshot.done? do
  IO.puts("Result: " <> inspect(agent_status.snapshot.result))
end

# Access snapshot fields via helpers
case Status.status(agent_status) do
  :success -> handle_success(agent_status)
  :failure -> handle_failure(agent_status)
  :running -> poll_again()
end

Delegate Helpers

The module provides convenience delegates to common snapshot fields:

  • status/1 - Returns the snapshot's status
  • done?/1 - Returns the snapshot's done? flag
  • result/1 - Returns the snapshot's result
  • details/1 - Returns the snapshot's details map

Summary

Functions

Returns strategy-specific details from the snapshot.

Returns whether the agent has reached a terminal state.

Creates a new Status from a map of attributes.

Returns the result from the snapshot (if any).

Returns the status from the snapshot (:idle, :running, :waiting, :success, :failure).

Types

t()

@type t() :: %Jido.AgentServer.Status{
  agent_id: binary(),
  agent_module: atom(),
  pid: any(),
  raw_state: map(),
  snapshot: any()
}

Functions

details(status)

@spec details(t()) :: map()

Returns strategy-specific details from the snapshot.

done?(status)

@spec done?(t()) :: boolean()

Returns whether the agent has reached a terminal state.

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, term()}

Creates a new Status from a map of attributes.

Returns {:ok, status} or {:error, reason}.

result(status)

@spec result(t()) :: term() | nil

Returns the result from the snapshot (if any).

status(status)

@spec status(t()) :: Jido.Agent.Strategy.status()

Returns the status from the snapshot (:idle, :running, :waiting, :success, :failure).