Function createGuardrailBlockedStream

  • 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

    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;
    }