Skip to main content

Create a Guard

This guide walks through authoring a new custom guard. If you only need to turn on one of Willow's built-in guards, see Enable a Guard and See It Fire instead.

Prerequisites​

Step 1: Start a new guard​

Open Control > Guards and select + Add Guard.

The Add a Guard dialog opens. It offers ready-made protection packages (Prompt Injection & Jailbreaks, PII & Personal Data, Secrets & Credentials, and Content Safety), a search box for individual guards, and a Runtime / Build-time picker. To build your own, select Start from scratch on the Custom Guard card.

The Guards page with the Runtime tab and the + Add Guard button in the top right

Step 2: Name the guard and choose its scope​

In New Guard, enter a Name and confirm the Slug and Description. Describe what the guard detects.

New Guard with Name, Slug, Description, Scope, and Create and Edit

In the same form, choose the guard's scope:

  • Runtime if it should evaluate live tool calls and responses through the gateway.
  • Build-time if it should evaluate toolkits and plugins when they are published.

See Guards: Runtime vs Build-time if you are unsure. The scope determines which tab the guard appears on afterward. Select Create & Edit to open its editor.

Step 3: Add checks​

A guard needs at least one check. On the Checks tab you have two paths:

  • Select + Add Check to add a check manually, then choose its type (Built-in, Regex, JSONata, LLM, or Function) and fill in its configuration.
  • Select Add with AI, describe what the check should detect, choose a Check Type (or leave it on Auto), and select Generate Check. This option appears only when Bring Your Own AI is configured.

After adding a check you may need to scroll down to see the new entry. Set each check's Certainty (the score it contributes when it matches), and use the toggle to enable it. Select Save Changes when you are done. See Guard check types for the full reference on each type.

Step 4: Set the threshold and action​

On the guard's Settings tab, under Behavior:

  • Set the threshold with the slider. The guard fires when any check scores at or above this value. Start around the built-in defaults (7/10 to 8/10) and tune from there.
  • Choose the Action: Redact to strip matched content, Warning to log without stopping, Require Approval to hold the call, or Block to stop it outright. Optionally add a Message shown to the user when the action is Block or Require Approval.
The guard editor Behavior section with a Threshold slider, an Action dropdown set to Block, and an optional Message field

Select Save Changes. Choosing between redacting and blocking is a policy decision: redact keeps calls flowing while removing sensitive parts, block stops the call entirely.

Step 5: Scope it with filters​

Open Filters and set the coverage for the guard type:

  • For a Runtime guard, choose whose traffic it checks under Who (AI agents, background agents, groups, user risk score). Then choose which traffic under What: tool calls, with their MCP servers and direction, and prompts. Each row is All, Specific, All except, or None, and every filter you set must match.
  • For a Build-time guard, choose Organization Level or User Level, then select the entity types to check.

Select Save Filters. See Guard filters for each control.

Step 6: Test in the Playground​

Select Playground and test representative content. Confirm that the content you intend to catch fires the guard and that benign content passes. See Guards Playground.

Step 7: Publish​

Enable the guard from its row toggle, or use Publish in the editor. A green Published badge appears and the guard goes live immediately. There is no separate deploy step.

Verify it worked​

  • The guard appears in the correct tab with a Published badge and its toggle on.
  • Its threshold and action match what you configured.
  • A Playground test with matching content shows the guard triggering, and benign content passes.
  • For a runtime guard, a real triggering call appears in Monitor > Logs when you filter Guard Action.