LlmCore.Agent.Components.BudgetGuard (llm_core v0.3.0)

Copy Markdown View Source

Enforces iteration budget limits.

If the current iteration count has reached max_iterations - 1 (i.e. this is the last allowed iteration), halts the pipeline with an error decision. Future extensions may add token budget and cost budget enforcement.

Skips processing when the decision is already :done (no tool calls) or when the pipeline is in error status.

Analogous to budget guard clauses in step-oriented loop executors: that check recursion depth before proceeding.

Summary

Functions

Checks iteration count against max_iterations.

Functions

call(ctx, opts)

Checks iteration count against max_iterations.

Parameters

  • ctx%Context{} with iteration and max_iterations
  • opts — ALF stage options (unused)

Returns

  • Unchanged context when within budget
  • Context with status: :error and decision: {:error, :budget_exceeded} when the iteration limit is reached