core beginner

State Ops Agent

Focused example for SetState, ReplaceState, DeleteKeys, SetPath, and DeletePath via pure cmd execution.

state stateops actions core-mechanics l1

Related guides and notebooks

lib/agent_jido/demos/state_ops/actions/set_nested_value_action.ex 21 lines
defmodule AgentJido.Demos.StateOps.SetNestedValueAction do
  @moduledoc """
  Sets a nested value using `StateOp.SetPath`.
  """

  alias Jido.Agent.StateOp

  use Jido.Action,
    name: "set_nested_value",
    description: "Sets nested value by path",
    schema: [
      path: [type: {:list, :atom}, required: true],
      value: [type: :any, required: true]
    ]

  @impl true
  def run(%{path: path, value: value}, _context) do
    {:ok, %{}, %StateOp.SetPath{path: path, value: value}}
  end
end