services/loop/guardrails

Tool loop guardrails — applies repetition/loop detection after tool execution. Moved from core/loop/guardrails.gleam (Stage 3). Uses service bundles instead of the monolithic LoopContext.

Values

pub fn apply_guardrails(
  env: types.LoopEnv,
  logger: types.LoggerBundle,
  guardrails: types.GuardrailService,
  history: List(message.Message),
  guardrail_state: hooks.LoopState,
  calls: List(message.ToolCall),
) -> #(List(message.Message), hooks.LoopState, Bool)

Apply guardrail checks after tool execution. Returns updated history, guardrail state, and a halted flag.

Search Document