Composable pipeline
Guardrails run in sequence; the first block short-circuits, a modify chains forward.
A composable, fail-closed guardrail pipeline for AI agents — mask credentials, redact PII, and block dangerous shell commands inline.
Apache-2.0 TypeScript library · fail-closed by default · deterministic checks, no model round-trip.
$ npm install @usetheo/trust-guardrailscoming to npmAn agent with tool access is one bad completion away from pasting an API key into a log, echoing a customer’s SSN, or running rm -rf / from a generated command. Theo Guardrails sits in the agent’s execution path and inspects every piece of content — user input, model output, tool calls, tool results — before it moves. It masks, redacts, or blocks synchronously, and when a guardrail itself fails, it fails closed.
Guardrails run in sequence; the first block short-circuits, a modify chains forward.
11 rules mask secrets to deterministic fakes and return a map to reverse them.
Email, credit card, phone, SSN; cards are Luhn-checked to cut false positives.
Blocks rm -rf /, piped-curl installs, sudo rm, chmod 777, dd, eval, and more.
A thrown guardrail blocks unless it opts into failOpen; the context is never mutated.
Any async ctx -> result function drops into the same pipeline.
import {
createGuardrailPipeline,
createCredentialMaskingGuardrail,
createPiiGuardrail,
createShellPatternGuardrail,
} from '@usetheo/trust-guardrails';
const pipeline = createGuardrailPipeline([
{ guardrail: createShellPatternGuardrail() },
{ guardrail: createCredentialMaskingGuardrail() },
{ guardrail: createPiiGuardrail({ strategy: 'redact' }) },
]);
const result = await pipeline.run({ direction: 'tool_input', content: userText });
// result.action: 'allow' | 'block' | 'modify'Compose a fail-closed guardrail pipeline over a tool call.
Agents are moving into production execution paths with real tool access. Comparison stated at a general level; competitor internals not asserted.
| Capability | Theo Guardrails | Guardrails AI | NeMo Guardrails | Lakera Guard |
|---|---|---|---|---|
| Runtime | In-process TS/ESM library | Python-first | Python | Hosted service |
| Enforcement | Inline, synchronous, fail-closed | Inline | LLM-in-the-loop | API call |
| Detection | Deterministic regex + Luhn | Validators | LLM / rules | Remote classifier |
| Directions guarded | input · output · tool_input · tool_output | Prompt-level | Prompt-level | Prompt-level |
| Restore after mask | Yes (reversible) | Rare | Rare | Rare |
Deterministic, in-process guardrails you own — no model round-trip, no service to call, fail-closed when it matters.
A single leaked credential or executed destructive command is a live incident, not a bug ticket. Theo Guardrails is the in-the-moment enforcement half of Theo’s trust layer.
$ npm install @usetheo/trust-guardrailscoming to npmRead the docs → docs.usetheo.dev
View the source → github.com/usetheodev/theo-trust