Raxol.Agent.Process (Raxol Agent v2.6.0)

Copy Markdown View Source

GenServer running the observe-think-act loop for an AI agent.

Each Agent.Process owns a terminal buffer and runs a configurable tick timer. On each tick:

  1. observe/3 -- reads buffer + recent events
  2. think/2 -- agent decides what to do
  3. act/3 -- agent writes to terminal or sends messages

On crash, the DynamicSupervisor restarts the process. The new instance calls ContextStore.load/1 then restore_context/1 to resume.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get the agent's current status.

Push an event into the agent's event buffer.

Pilot releases the agent's terminal back to the agent.

Send a directive to the agent.

Start an agent process.

Pilot takes over the agent's terminal.

Types

status()

@type status() ::
  :initializing | :thinking | :acting | :waiting | :paused | :taken_over

t()

@type t() :: %Raxol.Agent.Process{
  agent_id: atom(),
  agent_module: module(),
  agent_state: map(),
  backend: module(),
  backend_config: keyword(),
  event_buffer: [term()],
  pane_id: term(),
  status: status(),
  strategy: module() | nil,
  tick_ms: pos_integer(),
  tick_ref: reference() | nil
}

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a specification to start this module under a supervisor.

See Supervisor.

get_status(agent)

@spec get_status(pid() | atom()) :: map()

Get the agent's current status.

push_event(agent, event)

@spec push_event(pid() | atom(), term()) :: :ok

Push an event into the agent's event buffer.

release(agent)

@spec release(pid() | atom()) :: :ok | {:error, term()}

Pilot releases the agent's terminal back to the agent.

send_directive(agent, directive)

@spec send_directive(pid() | atom(), term()) :: :ok

Send a directive to the agent.

start_link(init_opts \\ [])

@spec start_link(keyword()) :: {:ok, pid()} | {:error, term()}

Start an agent process.

takeover(agent)

@spec takeover(pid() | atom()) :: :ok | {:error, term()}

Pilot takes over the agent's terminal.