Centralized state operation application for strategies.
Separates state operations (state mutations) from external directives. All strategies should use these helpers to ensure consistent behavior.
State Operation Types
StateOp.SetState- Deep merge attributes into stateStateOp.ReplaceState- Replace state wholesaleStateOp.DeleteKeys- Remove top-level keysStateOp.SetPath- Set value at nested pathStateOp.DeletePath- Delete value at nested path
Any other struct is treated as an external directive and passed through.
Summary
Functions
Merges action result into agent state.
Applies a list of state operations to the agent.
Helper to put a value at a nested path, creating intermediate maps if needed.
Functions
@spec apply_result(Jido.Agent.t(), map()) :: Jido.Agent.t()
Merges action result into agent state.
Uses deep merge semantics.
@spec apply_state_ops(Jido.Agent.t(), [struct()]) :: {Jido.Agent.t(), [struct()]}
Applies a list of state operations to the agent.
State operations modify agent state. External directives are collected and returned for the runtime to process.
Returns {updated_agent, external_directives}.
Helper to put a value at a nested path, creating intermediate maps if needed.