# `Jido.Agent.Strategy.State`
[🔗](https://github.com/agentjido/jido/blob/v2.3.0/lib/jido/agent/strategy/state.ex#L1)

Helper module for managing strategy-specific state within an Agent.

Strategy state is stored under the reserved key `:__strategy__` in `agent.state`.
This keeps all state within the Agent struct for serializability and snapshot/restore.

## Structure

The strategy state typically contains:
- `:module` - The strategy module managing this state
- `:status` - Current execution status (:idle, :running, :waiting, :success, :failure)
- `:data` - Strategy-specific data (e.g., BT cursor, LLM conversation history)

## Example

    # In a Behavior Tree strategy
    agent = Strategy.State.put(agent, %{
      module: __MODULE__,
      status: :running,
      tree: bt_definition,
      cursor: root_node
    })

    # Later, read the state
    state = Strategy.State.get(agent)
    state.cursor  # => root_node

# `status`

```elixir
@type status() :: :idle | :running | :waiting | :success | :failure
```

# `t`

```elixir
@type t() :: %{
  optional(:module) =&gt; module(),
  optional(:status) =&gt; status(),
  optional(:data) =&gt; term(),
  optional(atom()) =&gt; term()
}
```

# `active?`

```elixir
@spec active?(Jido.Agent.t()) :: boolean()
```

Check if the strategy is actively running (not idle or terminal).

# `clear`

```elixir
@spec clear(Jido.Agent.t()) :: Jido.Agent.t()
```

Clear strategy state, resetting to empty map.

# `get`

```elixir
@spec get(Jido.Agent.t(), t()) :: t()
```

Get the strategy state from an agent.
Returns the default if no strategy state exists.

# `key`

```elixir
@spec key() :: atom()
```

Returns the reserved key used for strategy state.

# `put`

```elixir
@spec put(Jido.Agent.t(), t()) :: Jido.Agent.t()
```

Put new strategy state into an agent.
Replaces any existing strategy state.

# `set_status`

```elixir
@spec set_status(Jido.Agent.t(), status()) :: Jido.Agent.t()
```

Set the strategy status.

# `status`

```elixir
@spec status(Jido.Agent.t()) :: status()
```

Get the current strategy status.
Returns :idle if no status is set.

# `terminal?`

```elixir
@spec terminal?(Jido.Agent.t()) :: boolean()
```

Check if the strategy is in a terminal state (success or failure).

# `update`

```elixir
@spec update(Jido.Agent.t(), (t() -&gt; t())) :: Jido.Agent.t()
```

Update strategy state using a function.
The function receives the current strategy state (or empty map) and returns the new state.

