Jido.Agent.Strategy.BehaviorTree (Jido Behavior Tree v1.0.0)

View Source

Behavior tree execution strategy for Jido agents.

This strategy allows agents to use behavior trees for decision-making. Each cmd/3 call executes exactly one behavior tree tick, making execution bounded and predictable.

Configuration

Configure via strategy options when defining an agent:

defmodule MyAgent do
  use Jido.Agent,
    name: "bt_agent",
    strategy: {Jido.Agent.Strategy.BehaviorTree,
      tree: my_tree(),
      blackboard: %{initial: "data"}
    }
end

Options

  • :tree - A Jido.BehaviorTree.Tree.t() (required unless :tree_builder provided)
  • :tree_builder - {mod, fun, args} to build tree dynamically per agent
  • :blackboard - Initial blackboard data map (default: %{})
  • :reset_on_completion - Reset tree when status is :success or :failure (default: false)

Execution Model

  1. init/2 - Creates tree and blackboard from options, stores in __strategy__
  2. cmd/3 - Injects instructions into blackboard, runs one tree tick, returns directives
  3. snapshot/2 - Maps tree status to Strategy.Snapshot

Status Mapping

  • Tree :success → Snapshot :success
  • Tree :failure → Snapshot :failure
  • Tree :running → Snapshot :running
  • Before first tick → Snapshot :idle