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

YAML
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_compliance

Reference

Top-level fields

FieldRequiredValues
nameYesA name for the policy.
versionYesA whole number, 1 or higher.
modeYesguardrail, passive or audit. See Modes.
severityYesinfo, warning or critical.
applies_to.agentsYesA list of agent names, or ["*"] for every agent, including agents you add later.
whenYesWhen the policy fires. See below.
thenYesWhat happens when it fires. See below.

when.stage

Each policy is checked at one stage of a run:

StageCheckedFields you can use
pre_callBefore an LLM call is forwarded by the proxy. Used by guardrails.gen_ai.request.model, gen_ai.provider.name, gen_ai.operation.name
post_callOn each LLM call, agent step and retrieval.Any attribute on the step, such as the three above.
tool_callOn each tool call.Any attribute on the step, such as gen_ai.tool.name.
run_completeOnce, 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:

OperatorHolds whenValue
equalsThe field equals the value.Text
not_equalsThe field is present and differs from the value.Text
containsThe field contains the value.Text
contains_patternThe field matches the regular expression anywhere in it.Regular expression
inThe field is one of the values.List of text
not_inThe field is present and is none of the values.List of text
in_listThe value is in the list field. Used with tools_used.Text
out_of_orderBoth 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

FieldValues
verdictallow, allow_with_flag, warn or block. See below.
messageThe explanation shown with the violation and in alerts.
dimensionThe trust-score dimension it affects: policy_compliance, security_risk, behavioral_consistency or tool_efficacy.
VerdictEffect
allowNothing is recorded.
allow_with_flagRecorded, with a small effect on the trust score.
warnRecorded; lowers the trust score, by more for higher severities.
blockRecorded 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

ModeBehaviour
passiveWatch and record. Violations are recorded and scored; nothing is blocked. Start here.
auditCurrently behaves exactly like passive. Use it to mark a policy as record-only.
guardrailEnforce 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

YAML
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_compliance

Require a tool in every run

YAML
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_compliance

Require tools in the right order

YAML
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_compliance

A 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.