BeamAgent.Guardrails (beam_agent v0.1.0)

Copy Markdown View Source

Thin dispatcher over the individual guardrail checks, each its own module: BeamAgent.Guardrails.MaxIterations, MaxContextMessages, MaxExecutionTime, and MaxToolCalls. All read their options from the same guardrails keyword list passed to BeamAgent.Runner.start_link/1 (via BeamAgent.API.run/2's :guardrails opt) — there's no shared config struct, each check just looks up its own key with its own default.

Summary

Functions

Time and iteration checks run before every step (MaxExecutionTime, MaxIterations).

Time, iteration, and tool-call checks run before every tool call (adds MaxToolCalls).

Delegates to MaxContextMessages.check/2, run after context compression.

Delegates to MaxIterations.check/2.

Functions

check_before_step(state, opts)

@spec check_before_step(
  BeamAgent.State.t(),
  keyword()
) :: :ok | {:error, term()}

Time and iteration checks run before every step (MaxExecutionTime, MaxIterations).

check_before_tool(state, opts)

@spec check_before_tool(
  BeamAgent.State.t(),
  keyword()
) :: :ok | {:error, term()}

Time, iteration, and tool-call checks run before every tool call (adds MaxToolCalls).

check_context(state, opts)

@spec check_context(
  BeamAgent.State.t(),
  keyword()
) :: :ok | {:error, term()}

Delegates to MaxContextMessages.check/2, run after context compression.

check_iterations(state, opts)

@spec check_iterations(
  BeamAgent.State.t(),
  keyword()
) :: :ok | {:error, term()}

Delegates to MaxIterations.check/2.