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
- GuardrailBlockedEvent for suppressed text
- GuardrailEvent for all guardrail event types
Extends
BaseEvent
Properties
| Property | Type | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|
guardrail | string | Name 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 |
original | string | Text the guardrail received. | - | - | src/core/events/types.ts:617 |
reason? | string | Explanation 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 |
text | string | Text the guardrail produced, which is what gets synthesized. | - | - | src/core/events/types.ts:620 |
timestamp | number | Unix timestamp (in milliseconds) when the event occurred. Remarks Useful for latency measurements and debugging the pipeline timing. | - | BaseEvent.timestamp | src/core/events/types.ts:86 |
type | "guardrail.applied" | Discriminant for this event type. | - | - | src/core/events/types.ts:602 |