# `Jido.Agent.StateBudget`
[🔗](https://github.com/agentjido/jido/blob/v2.4.0/lib/jido/agent/state_budget.ex#L1)

Enforces an optional byte budget for the complete agent state.

The size is the external term size from `:erlang.external_size/1`. It is
not the BEAM heap size. A `nil` limit disables the size calculation.

# `result`

```elixir
@type result() :: {:ok, Jido.Agent.t()} | {:error, Jido.Error.ValidationError.t()}
```

# `check`

```elixir
@spec check(Jido.Agent.t()) :: result()
```

Checks the full state and returns the agent or a structured error.

# `check!`

```elixir
@spec check!(Jido.Agent.t()) :: Jido.Agent.t()
```

Checks the state, raising a validation error if the budget is exceeded.

# `limit`

```elixir
@spec limit(Jido.Agent.t()) :: non_neg_integer() | nil
```

Returns the effective state budget, including the agent module's limit.

# `replace`

```elixir
@spec replace(Jido.Agent.t(), map()) :: result()
```

Replaces the state or returns a structured budget error.

# `replace!`

```elixir
@spec replace!(Jido.Agent.t(), map()) :: Jido.Agent.t()
```

Replaces the state, raising a validation error if the budget is exceeded.

# `transition`

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

Checks a proposed replacement while retaining the previous budget.
