Raxol.Agent.Turn (Raxol Agent v2.6.0)

Copy Markdown View Source

Drives one self-improving agent turn for an agent module.

This is where the memory, skills, and self-improvement pieces meet. run/3 assembles the tool context from the agent module's callbacks (memory_provider/memory_providers, skills_provider, self_improve), runs the framework ReAct loop (Raxol.Agent.Stream.react/2), records the turn into a Raxol.Agent.Conversation.Log, and then fires the after-turn side effects: background curation (Raxol.Agent.SelfImprove), a user-model refresh, and a session-search index update.

The agent module declares which providers it wants; the caller supplies the running instances through opts (store server names, the UserModel and SessionSearch servers).

Options

  • :backend (required) -- the AIBackend for the turn
  • :backend_opts -- extra opts passed to the backend
  • :log (required) -- the Conversation.Log server
  • :conversation_id (required)
  • :response_id -- tags recorded items with the turn id
  • :agent_id -- partitions memory
  • :user_id -- keys the user model and its context injection
  • :memory_opts / :skills_opts -- merged into the provider contexts (notably :server when a store runs under a non-default name)
  • :user_model -- the UserModel server; enables user-context injection and a background refresh after the turn
  • :session_search -- the SessionSearch server; enables the session_search action and indexes the turn's items
  • :max_iterations

Summary

Functions

Run the after-turn side effects for a recorded turn: trigger curation, refresh the user model in the background, and feed the session-search index.

Assemble the tool context (:memory, :skills, :user_context, :session_search) from the agent module's callbacks and the running instances in opts. Keys are present only when their capability is configured.

Functions

after_turn(agent_module, items, context, opts)

@spec after_turn(module(), [map()], map(), keyword()) :: :ok

Run the after-turn side effects for a recorded turn: trigger curation, refresh the user model in the background, and feed the session-search index.

build_context(agent_module, opts)

@spec build_context(
  module(),
  keyword()
) :: map()

Assemble the tool context (:memory, :skills, :user_context, :session_search) from the agent module's callbacks and the running instances in opts. Keys are present only when their capability is configured.

run(agent_module, prompt, opts)

@spec run(module(), String.t() | [map()], keyword()) :: {:ok, [map()]}