Veto/docs

Constraints Reference

Every constraint type supported by Veto — policy constraints, YAML rule operators, and presence checks.

Veto supports two constraint systems: policy constraints (configured in the dashboard or policy API) and YAML rule conditions (configured in veto/rules/*.yaml). Both work in local, cloud, and self-hosted modes.

Policy constraints

Policy constraints are configured per-tool in the Veto dashboard or via the policy API. They apply to both client-side and server-side deterministic validation.

Number constraints

ConstraintDescriptionExample
minimumValue must be ≥ thresholdminimum: 0 — no negative amounts
maximumValue must be ≤ thresholdmaximum: 10000 — cap at $10,000
greaterThanValue must be > thresholdgreaterThan: 0 — must be positive
lessThanValue must be < thresholdlessThan: 100 — below 100
greaterThanOrEqualAlias for minimumSame as minimum
lessThanOrEqualAlias for maximumSame as maximum

NaN and Infinity values always fail number constraints.

Example policy: Block transfers over $5,000

argument: amount
maximum: 5000

If the agent calls transfer_funds({ amount: 7500 }), it's denied with:

{
  "decision": "deny",
  "failedArgument": "amount",
  "reason": "amount 7500 exceeds maximum of 5000"
}

String constraints

ConstraintDescriptionExample
enumValue must exactly match one of the allowed stringsenum: ["USD", "EUR", "GBP"]
regexValue must match the regular expressionregex: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+$"
minLengthString must be at least N charactersminLength: 1 — no empty strings
maxLengthString must be at most N charactersmaxLength: 500 — limit message length

Regex patterns are capped at 256 characters and checked for ReDoS safety before execution.

Array constraints

ConstraintDescriptionExample
minItemsArray must have at least N elementsminItems: 1 — no empty lists
maxItemsArray must have at most N elementsmaxItems: 10 — limit batch size

Presence constraints

ConstraintDescriptionExample
requiredArgument must be present in the callrequired: true — can't omit this field
notNullArgument cannot be null/NonenotNull: true — must have a value

required checks that the key exists in the arguments object. notNull additionally checks that the value is not null.

YAML rule condition operators

YAML rules in veto/rules/*.yaml use a conditions array with field, operator, and value fields. These operators are evaluated locally in all modes.

OperatorTypeDescription
equalsanyExact match
not_equalsanyMust not equal
containsstringMust contain substring
not_containsstringMust NOT contain substring
starts_withstringMust start with prefix
ends_withstringMust end with suffix
matchesstringRegex pattern match (max 256 chars, ReDoS-safe)
instring/numberValue in allowlist (array)
not_instring/numberValue NOT in denylist (array)
greater_thannumberValue must be > threshold
less_thannumberValue must be < threshold

YAML examples

Block emails outside company domain:

rules:
  - id: company-email-only
    name: Restrict to company domain
    action: block
    tools:
      - send_email
    conditions:
      - field: arguments.to
        operator: matches
        value: "^[^@]+@company\\.com$"

Restrict currencies to allowlist:

rules:
  - id: allowed-currencies
    name: Only allow approved currencies
    action: block
    tools:
      - transfer_funds
    conditions:
      - field: arguments.currency
        operator: not_in
        value: ["USD", "EUR", "GBP"]

Block file writes outside project directory:

rules:
  - id: restrict-file-writes
    name: Block writes outside project
    action: block
    tools:
      - write_file
    conditions:
      - field: arguments.path
        operator: starts_with
        value: "/etc"

Block specific values:

rules:
  - id: no-admin-role
    name: Prevent assigning admin role
    action: block
    tools:
      - assign_role
    conditions:
      - field: arguments.role
        operator: equals
        value: "admin"

Block messages containing sensitive keywords:

rules:
  - id: no-secrets-in-messages
    name: Block messages with secret content
    action: block
    tools:
      - send_message
    conditions:
      - field: arguments.body
        operator: contains
        value: "password"

Combining constraints

Multiple constraints on the same argument are AND-ed together. A tool call is denied if any single constraint fails.

Example: Amount must be between 1 and 10,000 and is required

argument: amount
required: true
minimum: 1
maximum: 10000

Example: Email must be present and match a pattern

argument: email
required: true
regex: "^[^@]+@[^@]+\\.[^@]+$"
maxLength: 254

Disabling constraints

Set enabled: false on any constraint to skip it without deleting the configuration. Useful for temporarily relaxing a policy.

Python naming

The Python SDK uses snake_case equivalents:

TypeScriptPython
notNullnot_null
greaterThangreater_than
lessThanless_than
greaterThanOrEqualgreater_than_or_equal
lessThanOrEqualless_than_or_equal
minLengthmin_length
maxLengthmax_length
minItemsmin_items
maxItemsmax_items