Skip to main content
The content gate catches two failure modes that other gates cannot: an agent that returns nothing at all, and an agent that responds with a refusal rather than completing its assigned task. Both are treated as gate failures because they represent output that will not satisfy the user, even if the output is structurally valid. Both checks are enabled by default and can be turned off independently.

Usage

Empty output detection

The gate considers ctx.output empty if it is any of the following:
  • undefined or null
  • A string containing only whitespace (or an empty string)
  • An empty array ([])
  • An object with no own keys ({})
Any other value — including false, 0, or a non-empty string — is treated as non-empty.

AI refusal phrase detection

The gate scans every string in ctx.output for phrases that indicate the model is declining to fulfill the request rather than producing useful output. The following patterns are matched case-insensitively: The gate returns passed: false on the first match it finds. It does not enumerate all matching phrases.

What a failure looks like

Configuration

boolean
Fail evaluations where ctx.output is empty, whitespace-only, an empty array, or an empty object. Defaults to true.
boolean
Fail evaluations where any string in ctx.output matches a known AI refusal or disclaimer phrase. Defaults to true.
string
Override the gate name recorded in results. Defaults to "content".

Disabling a check

Place gates.content() early in your gate list. With failFast: true (the default), detecting an empty or refused output immediately aborts the remaining gates — avoiding schema validation and PII scanning on output that you are going to reject anyway.