View Source Jido.Agent behaviour (Jido v1.0.0-rc.1)

Defines an Agent within the Jido system.

An Agent represents a higher-level entity that can plan and execute a series of Actions. Agents are defined at compile-time and provide a consistent interface for planning, executing, and managing complex workflows.

Features

  • Compile-time configuration validation
  • Runtime input parameter validation
  • Consistent error handling and formatting
  • Extensible lifecycle hooks
  • JSON serialization support
  • Dynamic planning and execution of Action sequences

Usage

To define a new Agent, use the Jido.Agent behavior in your module:

defmodule MyAgent do
  use Jido.Agent,
    name: "my_agent",
    description: "Performs a complex workflow",
    category: "processing",
    tags: ["example", "demo"],
    vsn: "1.0.0",
    schema: [
      input: [type: :string, required: true]
    ]

  @impl true
  def plan(agent) do
    # Your planning logic here
    {:ok, %Jido.ActionSet{agent: agent, plan: [MyAction1, MyAction2]}}
  end
end

Callbacks

Implementing modules must define the following callback:

  • plan/1: Generates a plan (sequence of Actions) for the Agent to execute.

Summary

Types

t()

@type t() :: %Jido.Agent{
  category: String.t(),
  description: String.t(),
  name: String.t(),
  schema: NimbleOptions.schema(),
  tags: [String.t()],
  vsn: String.t()
}

Callbacks

plan(t)

@callback plan(t()) :: {:ok, Jido.ActionSet.t()} | {:error, any()}

Functions

format_config_error(error)

@spec format_config_error(NimbleOptions.ValidationError.t() | any()) :: String.t()

format_validation_error(error)

@spec format_validation_error(NimbleOptions.ValidationError.t() | any()) :: String.t()