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.
Summary
Functions
Checks the full state and returns the agent or a structured error.
Checks the state, raising a validation error if the budget is exceeded.
Returns the effective state budget, including the agent module's limit.
Replaces the state or returns a structured budget error.
Replaces the state, raising a validation error if the budget is exceeded.
Checks a proposed replacement while retaining the previous budget.
Types
@type result() :: {:ok, Jido.Agent.t()} | {:error, Jido.Error.ValidationError.t()}
Functions
@spec check(Jido.Agent.t()) :: result()
Checks the full state and returns the agent or a structured error.
@spec check!(Jido.Agent.t()) :: Jido.Agent.t()
Checks the state, raising a validation error if the budget is exceeded.
@spec limit(Jido.Agent.t()) :: non_neg_integer() | nil
Returns the effective state budget, including the agent module's limit.
@spec replace(Jido.Agent.t(), map()) :: result()
Replaces the state or returns a structured budget error.
@spec replace!(Jido.Agent.t(), map()) :: Jido.Agent.t()
Replaces the state, raising a validation error if the budget is exceeded.
@spec transition(Jido.Agent.t(), Jido.Agent.t()) :: result()
Checks a proposed replacement while retaining the previous budget.