Skip to content

GuardrailAppliedEvent

Emitted when a guardrail rewrites text on its way to the TTS provider.

Defined in: src/core/events/types.ts:600

Emitted when a guardrail rewrites text on its way to the TTS provider.

Remarks

The llm.chunk and llm.complete events still carry the raw model output — guardrails only change what is spoken. Subscribe here when the UI should show the redacted text instead, or to audit what was rewritten.

One event is emitted per guardrail that actually changed the text. A guardrail that passes text through unchanged is silent.

Example

agent.on('guardrail.applied', (event) => {
  console.log(`${event.guardrail} rewrote ${event.stage} text: ${event.reason}`);
});

See

Extends

  • BaseEvent

Properties

PropertyTypeDescriptionOverridesInherited fromDefined in
guardrailstringName of the guardrail that rewrote the text.--src/core/events/types.ts:605
metadata?Record<string, unknown>Detail supplied by the guardrail (matched categories, counts, scores).BaseEvent.metadata-src/core/events/types.ts:626
originalstringText the guardrail received.--src/core/events/types.ts:617
reason?stringExplanation supplied by the guardrail, if any.--src/core/events/types.ts:623
stage"chunk" | "final"Pipeline point at which it ran. Remarks 'chunk' for text filtered while streaming to a Live TTS provider, 'final' for a complete utterance.--src/core/events/types.ts:614
textstringText the guardrail produced, which is what gets synthesized.--src/core/events/types.ts:620
timestampnumberUnix timestamp (in milliseconds) when the event occurred. Remarks Useful for latency measurements and debugging the pipeline timing.-BaseEvent.timestampsrc/core/events/types.ts:86
type"guardrail.applied"Discriminant for this event type.--src/core/events/types.ts:602

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency