Function: createGuardrailBlockedStream()
createGuardrailBlockedStream(
context,evaluation,options?):AsyncGenerator<AgentOSResponse,void,undefined>
Defined in: packages/agentos/src/core/guardrails/guardrailDispatcher.ts:211
Create a stream that emits a single error chunk for blocked content.
Use this when input evaluation returns GuardrailAction.BLOCK to generate an appropriate error response without invoking orchestration.
Parameters
context
Guardrail context for the error details
evaluation
The blocking evaluation result
options?
Stream options (streamId, personaId)
Returns
AsyncGenerator<AgentOSResponse, void, undefined>
Async generator yielding a single ERROR chunk
Example
if (outcome.evaluation?.action === GuardrailAction.BLOCK) {
yield* createGuardrailBlockedStream(
guardrailContext,
outcome.evaluation,
{ streamId: 'stream-123', personaId: 'support-agent' }
);
return;
}