Policies
Write rules in plain YAML: the full policy reference, with operators, stages, verdicts and examples.
A policy is a rule about what your agents should or shouldn't do. You write it in plain YAML, not code, and Elgeon checks it against every step your agents take. When a policy fires, the violation is recorded against the run, the agent's trust score moves on the dimension you chose, and any matching alerts are sent.
Creating a policy
Open Policies in the dashboard. You can start from a one-click template, build a rule with the guided builder, or write the YAML yourself. Every policy is checked when you save it: an invalid one is rejected with a message saying exactly what's wrong, and is never stored.
The Free plan includes 3 policies; Starter and above have no limit. Guardrail-mode policies need the Growth plan. See Plans and billing.
- Editing a policy saves a new version. The full history is kept, and you can restore any earlier version.
- Creating, editing and deleting policies needs the admin or developer role, and each change is recorded in the audit log.
An example
policy:
name: "approved-models-only"
version: 1
mode: passive
severity: warning
applies_to:
agents: ["*"]
when:
stage: post_call
all:
- field: gen_ai.request.model
not_in:
- "gpt-4.1"
- "claude-opus-4-8"
then:
verdict: warn
message: "Agent used a model outside the approved list"
dimension: policy_complianceReference
Top-level fields
| Field | Required | Values |
|---|---|---|
name | Yes | A name for the policy. |
version | Yes | A whole number, 1 or higher. |
mode | Yes | guardrail, passive or audit. See Modes. |
severity | Yes | info, warning or critical. |
applies_to.agents | Yes | A list of agent names, or ["*"] for every agent, including agents you add later. |
when | Yes | When the policy fires. See below. |
then | Yes | What happens when it fires. See below. |
when.stage
Each policy is checked at one stage of a run:
| Stage | Checked | Fields you can use |
|---|---|---|
pre_call | Before an LLM call is forwarded by the proxy. Used by guardrails. | gen_ai.request.model, gen_ai.provider.name, gen_ai.operation.name |
post_call | On each LLM call, agent step and retrieval. | Any attribute on the step, such as the three above. |
tool_call | On each tool call. | Any attribute on the step, such as gen_ai.tool.name. |
run_complete | Once, when the run finishes. | tools_used (every tool the run called) and tool_order (the order they were first called in). |
when: conditions
List your conditions under exactly one of all (every condition holds), any (at least one holds) or none (none of them hold). Each condition names a field and one operator:
| Operator | Holds when | Value |
|---|---|---|
equals | The field equals the value. | Text |
not_equals | The field is present and differs from the value. | Text |
contains | The field contains the value. | Text |
contains_pattern | The field matches the regular expression anywhere in it. | Regular expression |
in | The field is one of the values. | List of text |
not_in | The field is present and is none of the values. | List of text |
in_list | The value is in the list field. Used with tools_used. | Text |
out_of_order | Both tools ran, and the first ran after the second. Only at run_complete, with tool_order. | Two tool names: "kyc_check,issue_payout" |
A condition on a field the step doesn't have is never true. So not_equals and not_in don't fire on steps that lack the field.
then
| Field | Values |
|---|---|
verdict | allow, allow_with_flag, warn or block. See below. |
message | The explanation shown with the violation and in alerts. |
dimension | The trust-score dimension it affects: policy_compliance, security_risk, behavioral_consistency or tool_efficacy. |
| Verdict | Effect |
|---|---|
allow | Nothing is recorded. |
allow_with_flag | Recorded, with a small effect on the trust score. |
warn | Recorded; lowers the trust score, by more for higher severities. |
block | Recorded with the largest effect. With mode: guardrail at pre_call, the request is also stopped. |
Every policy that fires is recorded as its own violation. When several guardrail policies fire on the same request, the strictest verdict decides whether it's stopped: block, then warn, then allow_with_flag, then allow.
Modes
| Mode | Behaviour |
|---|---|
passive | Watch and record. Violations are recorded and scored; nothing is blocked. Start here. |
audit | Currently behaves exactly like passive. Use it to mark a policy as record-only. |
guardrail | Enforce in real time. A pre_call policy with verdict block stops the request at the proxy. See Guardrails. |
More examples
Block denied models in real time
policy:
name: "block-denied-models"
version: 1
mode: guardrail
severity: critical
applies_to:
agents: ["*"]
when:
stage: pre_call
all:
- field: gen_ai.request.model
in:
- "gpt-3.5-turbo"
- "gpt-4o-mini"
then:
verdict: block
message: "Model is on the denylist"
dimension: policy_complianceRequire a tool in every run
policy:
name: "require-tool-in-run"
version: 1
mode: passive
severity: warning
applies_to:
agents: ["*"]
when:
stage: run_complete
none:
- field: tools_used
in_list: "fraud_check"
then:
verdict: warn
message: "Run finished without calling the required fraud_check tool"
dimension: policy_complianceRequire tools in the right order
policy:
name: "require-tools-in-order"
version: 1
mode: passive
severity: warning
applies_to:
agents: ["*"]
when:
stage: run_complete
any:
- field: tool_order
out_of_order: "kyc_check,issue_payout"
then:
verdict: warn
message: "issue_payout ran before the required kyc_check"
dimension: policy_complianceA longer sequence (A before B before C) is written as several before/after pairs. Tool names come from gen_ai.tool.name on your tool steps; see Connect your agents.