ACAgentic Craft

Advanced~28 minHazelJS

Guardrails and Tool I/O Hygiene

Import GuardrailsModule with AgentModule; redact PII and block injection on tool I/O—with config sketch.

Authors
editorial-team
Published
Last reviewed
Progress is stored locally in this browser.

Direct answer

GuardrailsModule + AgentModule enables automatic tool I/O checks. Configure redactPIIByDefault, blockInjectionByDefault, and blocklists. Guardrails complement Skillgate curation and PolicyEngine—they do not replace allow-lists.

Docs: Guardrails. Guide: /guides/secure-mcp-servers-and-agent-tools.

Worked example — module wiring

typescript
import { Module } from '@hazeljs/core';
import { AgentModule } from '@hazeljs/agent';
import { GuardrailsModule } from '@hazeljs/guardrails';

@Module({
  imports: [
    GuardrailsModule.forRoot({
      redactPIIByDefault: true,
      blockInjectionByDefault: true,
      // injectionBlocklist / toxicityBlocklist per package docs
    }),
    AgentModule.forRoot({ /* agents, llmProvider, ... */ }),
  ],
})
export class AppModule {}

Still curate tools:

typescript
const gate = Skillgate.fromOpenApi(spec, { include: { tags: ['agent'] } });
gate.register(registry, 'api-concierge');

Artifact: Guardrails config snippet reviewed by security

Sources

Related