Condition Matcher Reference
The ConditionGroup type provides declarative matching against invocation arguments. It is used in four contexts:
- Tool/skill approval conditions (
ApprovalConfig.conditionon tools and skills) -- determines when human approval is required (see Human-in-the-Loop Approval). - Delegation approval conditions (
ApprovalConfig.conditiononlocal_agents[]andremote_agents[]) -- determines when approval is required before delegating to a sub-agent (see Approval on Agent Delegation). - Loop exit conditions (
LoopConfig.exit_condition) -- determines when anagf.looppolicy stops iterating (see Execution Policies). - Conditional routing (
ConditionalRoute.when) -- determines which sub-agent anagf.conditionalpolicy routes to (see Execution Policies).
For tool/skill approval, args_match matches against tool arguments or skill arguments. For delegation approval, args_match uses path expressions referencing the parent's input. For execution policy contexts, args_match uses path expressions referencing parent input or step outputs. This page documents all supported match expressions.
Condition Structure
A condition is either a single ConditionGroup (AND semantics) or an array of ConditionGroups (OR-of-ANDs).
Single group: { args_match: { field1: matcher1, field2: matcher2 } }
Matches when ALL fields satisfy their matchers (AND)
Multiple groups: [ { args_match: { ... } }, { args_match: { ... } } ]
Matches when ANY group matches (OR)
Within each group, AND applies
Match Expressions
| Expression | Type | Meaning | YAML Example |
|---|---|---|---|
| Literal string | string | Exact string match | currency: "USD" |
| Literal number | number | Exact numeric match | quantity: 100 |
| Literal boolean | boolean | Exact boolean match | is_external: true |
{ gt: N } | Numeric comparison | Greater than N | amount: { gt: 10000 } |
{ gte: N } | Numeric comparison | Greater than or equal to N | amount: { gte: 100 } |
{ lt: N } | Numeric comparison | Less than N | risk_score: { lt: 0.5 } |
{ lte: N } | Numeric comparison | Less than or equal to N | risk_score: { lte: 0.5 } |
{ ne: V } | Inequality | Not equal to V (string, number, or boolean) | status: { ne: "approved" } |
{ pattern: "regex" } | Regex match | Matches the regex pattern | email: { pattern: ".*@external\\.com$" } |
{ in: [...] } | Set membership | Value is one of the listed values | category: { in: ["delete", "modify", "create"] } |
{ not_in: [...] } | Set exclusion | Value is NOT one of the listed values | region: { not_in: ["restricted", "embargoed"] } |
Evaluation Rules
- Single group (object): All matchers use AND logic -- every field must match.
- Multiple groups (array): Groups use OR logic. Within each group, AND applies. This gives OR-of-ANDs (disjunctive normal form).
- Arguments not mentioned in
args_matchare ignored (open-world assumption). - If a referenced argument is missing from the actual args, that matcher evaluates to false.
- Conditions are evaluated by the SDK at invocation time, before the approval request is sent.
- Empty
args_match: Ifargs_matchis present but empty (args_match: {}), the condition evaluates to true (vacuous truth -- no matchers means nothing to fail). This matches the open-world assumption: no constraints means all arguments are acceptable. - Empty
ConditionGroup: If aConditionGroupobject is present but contains noargs_matchfield, it is treated as{ args_match: {} }and evaluates to true. - Multiple operators in a single matcher: When a matcher object contains multiple operators (e.g.,
{ gt: 3, lt: 7 }), all operators MUST be satisfied (AND semantics). This allows range expressions:amount: { gte: 100, lte: 500 }means "amount between 100 and 500 inclusive." - Regex portability: The
patternmatcher MUST support a portable regex subset equivalent to RE2 (no backreferences, no lookahead/lookbehind, no possessive quantifiers). Runtimes MUST reject patterns that use features outside this subset. Patterns are unanchored by default -- use^and$for full-string matching.
Examples
AND: amount > 10000 AND currency is USD:
condition:
args_match:
amount: { gt: 10000 }
currency: "USD"
OR: amount > 10000 OR recipient is external:
condition:
- args_match:
amount: { gt: 10000 }
- args_match:
recipient_type: "external"
Complex OR-of-ANDs: (>100 recipients) OR (has attachment AND attachment > 10MB):
condition:
- args_match:
recipient_count: { gt: 100 }
- args_match:
contains_attachment: true
attachment_size_mb: { gt: 10 }
Key Format by Context
The args_match field appears in three distinct contexts. The key format differs depending on where the ConditionGroup is used:
Tool/skill approval context
Keys are plain argument names matching the tool or skill invocation parameters:
# Tool approval: keys match tool argument names
approval:
condition:
args_match:
amount: { gt: 1000 }
currency: "USD"
recipient_type: { in: ["external", "contractor"] }
Delegation approval context
Keys are path expressions referencing the parent agent's input. Since delegation approval gates whether a sub-agent is invoked (not a specific tool call), the relevant data is the parent's input context:
# Delegation approval: keys are path expressions referencing parent input
local_agents:
- alias: financial_executor
approval:
condition:
args_match:
parent.input.risk_level: { in: ["high", "critical"] }
Execution policy context
Keys are path expressions referencing the execution context:
# Loop exit condition: keys are path expressions
exit_condition:
args_match:
quality_checker.output.score: { gte: 0.9 }
parent.input.language: "en"
# Conditional routing: keys are path expressions
routes:
- when:
args_match:
parent.input.language: { in: ["en", "es", "fr"] }
agent: standard_translator
Summary
| Context | Key Format | Example Keys |
|---|---|---|
Tool/skill approval (local_tools[].approval, mcp_servers[].allowed_tools[].approval, remote_agents[].allowed_skills[].approval) | Plain argument names | amount, currency, recipient_type |
Delegation approval (local_agents[].approval, remote_agents[].approval) | Path expressions | parent.input.risk_level |
Loop exit condition (LoopConfig.exit_condition) | Path expressions | quality_checker.output.score |
Conditional routing (ConditionalRoute.when) | Path expressions | parent.input.language |