Anchorage API reference
    Preparing search index...

    Input passed to one policy evaluation.

    interface PolicyContext {
        channel: OutputChannel;
        messages: MastraDBMessage[];
        phase: PolicyPhase;
        requestContext?: RequestContext<unknown>;
        streamState?: Record<string, unknown>;
        text: string;
    }
    Index

    Properties

    channel: OutputChannel

    Output channel text came from. Always 'answer' in the input phase.

    messages: MastraDBMessage[]

    The gated messages. In the input phase, the messages text is read from: the message list's non-system caller messages. On Mastra's durable loop these come from the list's input messages; on generate() and stream() they also include the context and response messages a guarded agent's application input processors add. For a guarded agent, a message in both memory and input is represented by a copy restricted to the client tool outcomes the caller sends. History outside the call's input is excluded. Empty during streaming output — processOutputStream exposes no discrete messages — and empty at a standalone createContentPolicyGate boundary, which has only the rendered text.

    Lifecycle phase being evaluated.

    requestContext?: RequestContext<unknown>

    Mastra request context associated with the agent call.

    streamState?: Record<string, unknown>

    Streaming only: a scratch object private to this policy instance that persists across the chunks of one stream (absent in the input/result phases). Evaluators MAY keep incremental-scan cursors here (see denyPatterns); evaluators that ignore it stay pure and re-scan text.

    text: string

    Concatenated text of the gated content: input messages, one channel of the streamed output accumulated so far, or the final output result. Inside a guarded agent the input text also holds the text of each system message and each other message its application input processors add or change, and a remembered message carrying the caller's client tool outcome that one of them keeps but moves out of the input, read whole with its stored history. Each recorded version contributes text, including the version the breakwater-client-tool-output step leaves after mapping results in a message of the call's input; a version still among messages is read there, not again.