GuardrailsConfig
Configuration for the guardrail filter chain.
Defined in: src/core/types/guardrails.ts:269
Configuration for the guardrail filter chain.
Examples
import {
CompositeVoice,
createPIIRedactionGuardrail,
createPronunciationGuardrail,
} from 'composite-voice';
const agent = new CompositeVoice({
providers: [...],
guardrails: {
filters: [
createPIIRedactionGuardrail({ types: ['email', 'phone', 'ssn'] }),
createPronunciationGuardrail({
replacements: { SQL: 'sequel', kubectl: 'kube control' },
}),
],
},
});
const agent = new CompositeVoice({
providers: [...],
guardrails: {
mode: 'buffered',
onError: 'block',
timeoutMs: 2000,
filters: [createModerationGuardrail({ moderate })],
},
});
See
Guardrail for the filter interface.
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
enabled? | boolean | true | Whether the chain is active. Remarks Set to false to disable guardrails without removing the configuration — useful for A/B rollouts and debugging. | src/core/types/guardrails.ts:288 |
filters | readonly Guardrail[] | undefined | Filters to run, in order. Remarks Each guardrail receives the output of the previous one. The chain stops at the first guardrail that blocks. | src/core/types/guardrails.ts:277 |
maxSegmentChars? | number | 240 | Maximum characters buffered before a segment is flushed without a sentence boundary. Remarks Bounds worst-case latency when a model emits a long run of text with no punctuation. The cut is made at the last whitespace when possible. Only applies to 'sentence' segmentation. | src/core/types/guardrails.ts:317 |
mode? | GuardrailMode | 'streaming' | Whether to filter while streaming or to buffer the whole response first. See GuardrailMode | src/core/types/guardrails.ts:296 |
onError? | GuardrailErrorPolicy | 'passthrough' | What to do when a guardrail throws or times out. See GuardrailErrorPolicy | src/core/types/guardrails.ts:338 |
segmentation? | GuardrailSegmentation | 'sentence' | How streaming text is cut into units before filtering. See GuardrailSegmentation | src/core/types/guardrails.ts:304 |
timeoutMs? | number | 1000 | Per-guardrail time limit, in milliseconds. Remarks A guardrail that has not settled within this window is treated as failed and handled according to GuardrailsConfig.onError. Set to 0 to wait indefinitely — not recommended for network-bound checks, since a hung request stalls the whole turn. | src/core/types/guardrails.ts:330 |