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 LLM-judged egress 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 guardrails directly in lobu.config.ts via guardrailsInline — including LLM judges for input, output, pre-tool, or egress (LLM-judged egress). A pre-tool judge may be narrowed to named tools; a require-tool kind enforces that a tool was actually used.

Skills cannot add guardrails: a skill is instruction text only and can never change authority. Operator exclusions apply last.

The effective set is the union of agent built-ins and operator inline judges.

Every trip writes a guardrail-trip event. Operators can inspect it, and automations 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 caches and circuit breakers.

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