Skip to content
API Blog

Guardrails

Guardrails enforce policy outside the agent prompt. They still run when a prompt is weak, a model is confused, or a user tries to override instructions.

StageInspectsResult
inputUser message before dispatchReject the turn
outputAgent response before deliveryBlock the response
pre-toolTool name and argumentsDeny the call
egress judgeSelected outbound HTTP requestsAllow or block the request

Use Egress judge for outbound content policy.

NeedUse
Tell the model how to behaveSOUL.md or a skill
Hide or expose toolsTool policy
Enforce policy even if the model ignores instructionsGuardrail
Restrict network destinationsAgent network policy
NameStagePurpose
secret-scanoutputBlocks credential-shaped strings
pii-scaninput, output, pre-toolDetects common PII patterns
forbidden-toolspre-toolBlocks a fixed destructive-tool deny list
const assistant = defineAgent({
id: "assistant",
dir: "./agents/assistant",
guardrails: ["secret-scan", "pii-scan", "forbidden-tools"],
});

See the lobu.config.ts reference.

Operators can add inline LLM judges for input, output, or pre-tool. A pre-tool judge may be narrowed to named tools.

Skills may add pre-tool guardrails for the tools they introduce, but cannot:

  • weaken input or output guardrails
  • pre-approve their own destructive operations
  • override the operator’s disabled list

The effective set is the union of agent built-ins, operator inline judges, and enabled skill guardrails. Operator exclusions apply last.

Every trip writes a guardrail-trip event. Operators can inspect it, and behaviors can group repeated failures into eval cases or proposed policy changes.

Unresolved built-in names are logged and skipped, so check startup logs after changing names.

Deterministic guardrails should return a verdict rather than throw. The common runner treats an unexpected exception as a pass so an infrastructure failure does not wedge every turn. LLM judges have separate cache and circuit-breaker behavior.

Use deployment-specific controls when strict fail-closed behavior is required.