Jido. BehaviorTree. Nodes. Action
(Jido Behavior Tree v1.0.0)
View Source
A leaf node that executes a Jido Action.
The Action node wraps a Jido Action module and executes it when ticked. The action result is converted to behavior tree statuses:
{:ok, result}->:success{:error, reason}->{:error, reason}
Parameters are passed to the action and can include values from the blackboard.
Example
action = Action.new(MyApp.Actions.SendEmail, %{
to: "user@example.com",
subject: "Hello"
})Using Blackboard Values
You can reference blackboard values using the :from_blackboard option:
action = Action.new(MyApp.Actions.ProcessData, %{
data: {:from_blackboard, :input_data}
})
Summary
Functions
Creates a new Action node for the given action module.
Returns the Zoi schema for this module
Context-aware tick that integrates with Jido Agent Effects.
Types
Functions
Creates a new Action node for the given action module.
Parameters
action_module- The Jido Action module to executeparams- Parameters to pass to the action (default: %{})context- Context to pass to the action (default: %{})
Examples
iex> Action.new(MyAction)
%Action{action_module: MyAction, params: %{}, context: %{}}
iex> Action.new(MyAction, %{input: "value"})
%Action{action_module: MyAction, params: %{input: "value"}, context: %{}}
Returns the Zoi schema for this module
@spec tick_with_context(t(), Jido.BehaviorTree.Tick.t()) :: {Jido.BehaviorTree.Status.t(), t(), Jido.BehaviorTree.Tick.t()}
Context-aware tick that integrates with Jido Agent Effects.
When called via Tree.tick_with_context/2, this function:
- Resolves params from the blackboard
- Builds a Jido Instruction with agent state context
- Executes via
Jido.Exec.run/1 - Applies results and effects to the agent via
Jido.Agent.Effects - Accumulates directives on the tick
- Updates the blackboard with last_result
Returns a 3-tuple {status, updated_node, updated_tick}.