Availability
The Wolf Defender guardrail is available from Tyk AI Studio 2.3.0.
Overview
The Wolf Defender guardrail is a prompt-injection classifier for agent traffic. It runs the Wolf Defender Jev model by Patronus Protect (Casdo Labs GmbH). Tyk packages the model as a service with an HTTP API that AI Studio calls as a guardrail. The guardrail scores four stages of an agent conversation:
For each stage, the guardrail reports three detector levels:
<stage>.review, <stage>.block, and <stage>.critical. A detector matches its own level and the levels above it, so tool_result.block acts on block and critical findings. To act differently on each level, use two filters. For example, one filter stops the conversation on tool_result.critical, and the other quarantines on tool_result.block.
The guardrail also does these things in addition to the model:
- It applies rules without the model. Some tool calls are critical immediately. Examples are a call that reads credentials, sends a file over the network, or contains a planted canary string. The guardrail also flags hidden text, such as Unicode tag characters and bidirectional controls.
- It keeps a verdict store. Agents send the full history again with each request. The guardrail answers known text from its store. A flagged tool result stops each later request in the same conversation.
- It reads a versioned YAML policy. The policy holds the thresholds and the enforcement mode of each stage. It also holds a description of each app and switches that stop the scoring. The guardrail reloads the policy when the file changes.
How It Fits
Request filters send user messages, tool results, and tool definitions to the guardrail. Response filters send the tool calls of the model. The guardrail returns findings, and the filter applies its action.Choose a Deployment
Tyk publishes two images. Both images and the model are under the MIT License.
The CPU figures come from a container with 4 CPUs. The GPU figures come from an NVIDIA A40. Your figures can be different.
On a CPU, a long tool result takes several seconds. You set the scoring mode of each stage in the guardrail policy:
- Deferred: the guardrail lets new content through immediately and scores it in the background. The agent sends its history again, so the guardrail stops the next request that contains the same content. Use it for long content on a CPU.
- Inline: a flagged tool result never gets to the model. On a GPU, use inline mode for all stages.
image@sha256:...). Do not use a tag that can move.
Run the Guardrail on a CPU
Run the CPU image in the same Docker Compose project as AI Studio and the Edge Gateways. The guardrail has no network. AI Studio and the Edge Gateways connect to it through a Unix socket on a shared volume.-
Create a token and write it to
wolfguard.envasWOLFGUARD_TOKEN=<token>. The guardrail does not start without a token.- Set the file mode to
0600. - Do not commit the file.
- Set the file mode to
-
Create the state directory. The guardrail runs as user
10001and group65532. -
Add the guardrail service, the socket volume, and the socket settings to your Compose file:
-
Start the services:
The guardrail is healthy when it has loaded the model. This takes 20 to 60 seconds.
/run/wolfguard/wolfguard.sock with mode 0660 and group 65532. The AI Studio and Edge Gateway images run with this group, so only they can connect.
Set GUARDRAIL_UNIX_SOCKET_ALLOWLIST, and mount the socket volume, on AI Studio and on each Edge Gateway that runs the filter. The value /run/wolfguard/ allows all sockets in that directory. AI Studio refuses a socket that is not in the list.
Run the Guardrail on a GPU
Runtykio/ai-studio-guardrail-wolf-gpu on a host with an NVIDIA GPU. The image listens on TCP port 8000 and keeps its state in /workspace/wolfguard.
- Put a TLS proxy in front of the guardrail. The HTTP classifier trusts only publicly trusted certificates.
- In WOLFGUARD_ALLOW_IPS, list the outbound addresses or CIDR ranges of AI Studio and of each Edge Gateway. The guardrail refuses other addresses with HTTP 403.
- A proxy can hide the address of the caller. In this case, set WOLFGUARD_CLIENT_IP_HEADER to a header that only the proxy can set. Set WOLFGUARD_TRUSTED_PROXIES to the addresses of the proxy.
- To use your own policy, set WOLFGUARD_POLICY_YAML_B64 to the policy in base64.
Store the Token in AI Studio
- Go to Settings > Secrets and add a secret with the name
WOLFGUARD_TOKEN. - Set the value to the same token as the guardrail.
$SECRET/WOLFGUARD_TOKEN. Thus, the filter does not contain the token. For more information, refer to Secrets and Provider Credentials.
Give the Agent Its Own LLM
A filter attaches to an LLM and applies to all apps that use that LLM. If the agent shares an LLM with other apps, do these steps:- Create a second LLM with the same vendor, endpoint, key, and models.
- Give access to the new LLM only to the app of the agent.
- Attach the Wolf Defender filters to the new LLM.
Create the Filters in Log-Only Mode
Start in shadow mode with the Log only action. In shadow mode, the gateway does not wait for the guardrail and does not change traffic. It records each decision as a compliance event that shows what enforcement would do. Run shadow mode on real traffic for about two weeks before you enforce.Request Filter
Go to Context management > Filters, select Add filter, and set these fields:
- Threshold
0.01: The guardrail policy holds the real thresholds, and the guardrail reports only decided findings. The gateway drops a finding below the detector threshold. The default threshold is 0.5, so the gateway would drop review findings. ?policy=in the path: This parameter names the policy version that you expect. Use theversionvalue from the policy file. When you change the policy, you also edit the filter, and the guardrail counts calls that name a different version.- Verdict reuse off: The guardrail keeps its own verdict store. If the gateway also keeps verdicts, it can reuse a “not scored yet” answer from deferred mode. Then the stored verdict does not get to the request.
- Max pieces
2000: With verdict reuse off, the gateway sends the full history with each request. The guardrail answers known text from its store. A long conversation has more than the default of 256 pieces, and pieces over the limit are not scanned. - Timeout
30000: Inline scoring of a long tool result can take several seconds on a CPU. KeepWOLFGUARD_QUEUE_WAITon the guardrail (default 20 seconds) less than the timeout. Then a busy guardrail replies before the gateway stops waiting.
Response Filter for Tool Calls
Add a second filter for the tool calls of the model. Use the same provider, endpoint, and API key, and set these fields:- Is this a Response Filter?: On
- Detectors:
tool_call.blockandtool_call.review, each with a Threshold of0.01 - Scan tool calls: On
- On detection: Log only
- Shadow (don’t wait): On
- Reuse verdicts for text already scanned: Off
- Timeout (ms):
30000
Read Trusted Prompt Templates
An administrator can approve the instructions of an app as a trusted prompt template. Request guardrails then score only the parts that change. From image version 0.2.0, the Wolf Defender guardrail can process trusted prompt templates itself. To turn this on, select Reads trusted prompt templates in the connection of the request filter. The guardrail then scores the variable parts and also scores the full message in the same call as a backstop. Without this setting, the gateway sends only the variable parts and scores the full message in a second call.Create the Filters with the API
The API uses the same settings as the form. For the field names and the filters endpoint, refer to the AI Studio API reference. The Reads trusted prompt templates setting is the connection fieldtemplates: "true".
Attach and Check the Filters
- Go to Model management > Model providers, open the LLM, and add both filters. Filters run from top to bottom. The first block stops the request.
- If you use Edge Gateways, wait until AI Studio pushes the configuration to them.
-
In the Test panel of the request filter, set Request body format to the vendor format of your agent. Then select Insert a tool-result sample and run the test.
- The result shows a
tool_resultcompliance event. - The test is a real call, so it also checks the endpoint, the socket allowlist, and the token.

- The result shows a
- Send one real turn from the agent. Go to Governance > Compliance overview and select the Filter Events tab. The decisions show as shadow events, with the stage, the tool name, and the score.

Tune the Policy
Examine the shadow decisions each week before you enforce. Use these sources:- Compliance events in AI Studio: What the guardrail flagged, by stage, app, and tool.
- The decision log of the guardrail: The file
decisions.jsonlin the state directory has one line for each scored segment.- Each line has the scores, the stage, the app, and the tool. It also has the policy version and the SHA-256 hash of the text, but not the text.
- With
WOLFGUARD_PREVIEW=1, the filepreviews.jsonlkeeps the first 200 characters of each flagged segment, with secrets masked.
- Metrics: The guardrail serves Prometheus metrics on
/metrics, with the bearer token.
/etc/wolfguard/policy.yaml in the image. To use your own policy, mount a file at that path, or set WOLFGUARD_POLICY_YAML_B64 on a GPU host. Increase the version value for each change, and update ?policy= in the filters.
The guardrail reloads the file within 2 seconds. If the new file is not valid, the guardrail keeps the last valid policy.
These policy settings are the most useful to tune:
For all policy fields, refer to the policy reference in the guardrail repository.
During the shadow period, expect these results:
Enforce the Guardrail
Enforce one stage at a time. Wait one week between stages and examine the decisions. Replace the shadow request filter with these filters, in this order on the LLM:- Stop the conversation: Start with the detector
tool_result.critical. Adduser_message.blockwhen the user-message decisions are correct.- Set On detection and Action on tool results to Block.
- Set a Block message, for example “This conversation was stopped by the security guardrail.”
- Turn off Shadow (don’t wait). Keep the other settings from the shadow filter.
- Quarantine the other tool results: Set the detector to
tool_result.block.- Set On detection to Log only and Action on tool results to Quarantine.
- Set a Quarantine placeholder, for example
[content removed by policy: {{tool_name}} returned text that looked like instructions to the AI]. - Turn off Shadow (don’t wait).
- Block tool calls: In the response filter, set the detector to
tool_call.blockand Action on tool calls to Block. Turn off Shadow (don’t wait). - Remove poisoned tools: Add
tool_definition.blockto the quarantine filter. Turn on Scan tool definitions and set Action on tool definitions to Remove the tool.
- A blocked request gets the block message with HTTP 400.
- A quarantined tool result gets to the model as the placeholder, and the agent continues.
- A blocked tool call ends the response with the error event of the vendor.
secrets and leak detectors. Start it in shadow mode.
Operate the Guardrail
Turn Off Quickly
Use these methods, from the fastest:- In AI Studio, set the actions of the filters to Log only.
- In the policy,
skipan app, increase a threshold, or change the mode of a stage. The change takes effect within 2 seconds. - Detach the filters, then stop the guardrail. If you stop the guardrail first, filters that block tool results also block each request that contains a tool result.
Remove a False Flag
To remove one flag, find thesha256 value of the text in the compliance event or in the decision log. Then use the admin API of the guardrail, or the store command in the container. Refer to the guardrail repository for the commands. A change of the policy version removes all flags.
Monitor the Guardrail
If the GPU host stops, alert on
aistudio_guardrail_errors_total. Then set the filters to Log only, or point them to a CPU guardrail next to the gateway. A CPU guardrail has its own empty verdict store.
Do not rotate or truncate verdicts.db. The guardrail removes old rows itself.