> For the complete documentation index, see [llms.txt](https://ai-security-docs.akto.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-security-docs.akto.io/agentic-guardrails/how-to/create-guardrail-policies/custom-usage-and-anomaly.md).

# Custom, Usage, and Anomaly Guardrails

Configure custom LLM-based rules, usage limits, and anomaly detection for a guardrail policy.

This page covers part of the [Create Guardrail Policies](https://ai-security-docs.akto.io/agentic-guardrails/how-to/create-guardrail-policies.md) form.

## Custom Guardrails

**LLM prompt based rule**

This rule uses an LLM to classify content against a custom prompt.

* Define the **evaluation prompt**.
* Configure a **confidence score threshold**.
* Content is blocked when the model confidence exceeds the configured threshold.

**LLM based redaction**

This rule uses an LLM to mask sensitive content described in plain language, instead of blocking the request or response outright.

* Enable **LLM based redaction**.
* Define the **redaction instruction** describing what to mask, for example "Redact customer full names and home addresses." Be specific: only content matching the instruction is masked, and anything not described is left untouched. To redact a second, unrelated category, create another policy.
* Matching text is replaced in place and the request is allowed through, instead of being blocked.

**External model based evaluation**

External evaluation allows integration with third-party or internal scoring systems.

* Provide the **external evaluation endpoint URL**.
* Configure a **confidence threshold** that determines enforcement actions based on the external response.

<div data-with-frame="true"><figure><img src="https://1895868029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkpBG2Nfd5ZbNmahr8W6H%2Fuploads%2Fgit-blob-600e9789b02529bb5a38470f71ee47e9a5817215%2Fimage%20(223).png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

## Usage Based Guardrails

**Token Limit Detection**

Akto can evaluate input size and detects requests that exceed acceptable token limits.

* Enable token limit detection and set the confidence threshold.

**Behaviour**

* Higher threshold values allow larger inputs.
* Lower threshold values enforce stricter limits and block oversized requests.

<div data-with-frame="true"><figure><img src="https://1895868029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkpBG2Nfd5ZbNmahr8W6H%2Fuploads%2Fgit-blob-8faa59215f9fbaf74c36d09a76b057e3e880fa46%2Fimage%20(166).png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

## Anomaly Detection

Configure anomaly detection rules to identify unusual patterns in agent behaviour, tool usage, and system metrics.

Anomaly detection guardrails are tagged with the OWASP Agentic risk categories they help mitigate, for example **ASI07 – Insecure Inter-Agent Communication**, **ASI08 – Cascading Failures**, and **ASI10 – Rogue Agents**.

**Statistical Anomalies**

* Enable **anomaly detection** to detect and alert on abnormal tool call counts and error counts per session.
* Set the **Tool call limit (per session)**: total tool calls allowed per session before triggering an anomaly.
* Set the **Error limit (per session)**: total errors (4xx/5xx) per session before triggering an anomaly.

<div data-with-frame="true"><figure><img src="https://1895868029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkpBG2Nfd5ZbNmahr8W6H%2Fuploads%2Fgit-blob-6a2bb6dc5133543edb25377f3a3c0519756e8bb3%2Fimage%20(219).png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

**Structural Anomalies**

Detects irregularities in request structure or interaction flows, with configuration options rolling out.

**Behavioral Anomalies**

Identifies unexpected agent actions or tool usage patterns, with configuration options rolling out.
