Anchorage API reference
    Preparing search index...

    Application output processor accepted by createGuardedAgent.

    Both stream and final-result hooks are required so the processor enforces the same rule on stream() and generate().

    interface GuardedOutputProcessor {
        computeStateSignal?: undefined;
        description?: string;
        id: string;
        name?: string;
        onViolation?: (violation: ProcessorViolation) => void | Promise<void>;
        processAPIError?: undefined;
        processDataParts?: boolean;
        processInput?: undefined;
        processInputStep?: undefined;
        processLLMRequest?: undefined;
        processLLMResponse?: undefined;
        processOutputResult: (
            args: ProcessOutputResultArgs<unknown>,
        ) => ProcessorMessageResult;
        processOutputStep?: undefined;
        processOutputStream: (
            args: ProcessOutputStreamArgs<unknown>,
        ) => Promise<ChunkType | null | undefined>;
    }
    Index

    Properties

    computeStateSignal?: undefined
    description?: string
    id: string
    name?: string
    onViolation?: (violation: ProcessorViolation) => void | Promise<void>
    processAPIError?: undefined
    processDataParts?: boolean
    processInput?: undefined
    processInputStep?: undefined
    processLLMRequest?: undefined
    processLLMResponse?: undefined
    processOutputResult: (
        args: ProcessOutputResultArgs<unknown>,
    ) => ProcessorMessageResult

    Type Declaration

      • (args: ProcessOutputResultArgs<unknown>): ProcessorMessageResult
      • Process the complete output result after streaming/generate is finished

        Parameters

        • args: ProcessOutputResultArgs<unknown>

        Returns ProcessorMessageResult

        Either:

        • MessageList: The same messageList instance passed in (indicates you've mutated it)
        • MastraDBMessage[]: Transformed messages array (for simple transformations)
    processOutputStep?: undefined
    processOutputStream: (
        args: ProcessOutputStreamArgs<unknown>,
    ) => Promise<ChunkType | null | undefined>

    Type Declaration

      • (args: ProcessOutputStreamArgs<unknown>): Promise<ChunkType | null | undefined>
      • Process output stream chunks with built-in state management This allows processors to accumulate chunks and make decisions based on larger context Return null or undefined to skip emitting the part

        Parameters

        • args: ProcessOutputStreamArgs<unknown>

        Returns Promise<ChunkType | null | undefined>