Lux.Agent behaviour (Lux v0.5.0)

View Source

A Agent defines an autonomous agent's capabilities, behaviors and goals. The actual execution and supervision is handled by the Lux runtime.

Agents can be configured with different templates that provide specialized behaviors:

  • :company_agent - Adds company-specific signal handling
  • (other templates to be added)

Example

defmodule MyCompanyAgent do
  use Lux.Agent,
    template: :company_agent,
    template_opts: %{
      llm_config: %{temperature: 0.7}
    } do

    def init(opts) do
      {:ok, opts}
    end

    # Can override template functions if needed
    def handle_task_assignment(signal, context) do
      # Custom implementation
    end
  end
end

Summary

Types

collaboration_protocol()

@type collaboration_protocol() :: :ask | :tell | :delegate | :request_review

memory_config()

@type memory_config() :: %{backend: module(), name: atom() | nil}

scheduled_action()

@type scheduled_action() :: {module(), pos_integer(), map(), map()}

scheduled_beam()

@type scheduled_beam() :: {module(), String.t(), keyword()}

signal_handler()

@type signal_handler() :: {module(), module() | {:python, String.t()}}

t()

@type t() :: %Lux.Agent{
  accepts_signals: [Lux.SignalSchema.t()],
  beams: [Lux.Beam.t()],
  description: String.t(),
  goal: String.t(),
  id: String.t(),
  lenses: [Lux.Lens.t()],
  llm_config: map(),
  memory_config: memory_config() | nil,
  memory_pid: pid() | nil,
  module: module(),
  name: String.t(),
  prisms: [Lux.Prism.t()],
  scheduled_actions: [scheduled_action()],
  signal_handlers: [signal_handler()],
  template: atom(),
  template_opts: map()
}

Callbacks

chat(t, message, opts)

@callback chat(t(), message :: String.t(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}

Functions

chat(agent, message, opts)

from_json(source)

Creates an agent module from JSON configuration. See Lux.Agent.Loaders.from_json/1 for details.

get_handler_type(handler)

inject_template(arg1, template_opts)

(macro)

module_to_name(module)

schedule_action(name, module, interval_ms, input, opts)