Skip to main content

Condition Matcher Reference

The ConditionGroup type provides declarative matching against invocation arguments. It is used in four contexts:

  1. Tool/skill approval conditions (ApprovalConfig.condition on tools and skills) -- determines when human approval is required (see Human-in-the-Loop Approval).
  2. Delegation approval conditions (ApprovalConfig.condition on local_agents[] and remote_agents[]) -- determines when approval is required before delegating to a sub-agent (see Approval on Agent Delegation).
  3. Loop exit conditions (LoopConfig.exit_condition) -- determines when an agf.loop policy stops iterating (see Execution Policies).
  4. Conditional routing (ConditionalRoute.when) -- determines which sub-agent an agf.conditional policy 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

ExpressionTypeMeaningYAML Example
Literal stringstringExact string matchcurrency: "USD"
Literal numbernumberExact numeric matchquantity: 100
Literal booleanbooleanExact boolean matchis_external: true
{ gt: N }Numeric comparisonGreater than Namount: { gt: 10000 }
{ gte: N }Numeric comparisonGreater than or equal to Namount: { gte: 100 }
{ lt: N }Numeric comparisonLess than Nrisk_score: { lt: 0.5 }
{ lte: N }Numeric comparisonLess than or equal to Nrisk_score: { lte: 0.5 }
{ ne: V }InequalityNot equal to V (string, number, or boolean)status: { ne: "approved" }
{ pattern: "regex" }Regex matchMatches the regex patternemail: { pattern: ".*@external\\.com$" }
{ in: [...] }Set membershipValue is one of the listed valuescategory: { in: ["delete", "modify", "create"] }
{ not_in: [...] }Set exclusionValue is NOT one of the listed valuesregion: { not_in: ["restricted", "embargoed"] }

Evaluation Rules

  1. Single group (object): All matchers use AND logic -- every field must match.
  2. Multiple groups (array): Groups use OR logic. Within each group, AND applies. This gives OR-of-ANDs (disjunctive normal form).
  3. Arguments not mentioned in args_match are ignored (open-world assumption).
  4. If a referenced argument is missing from the actual args, that matcher evaluates to false.
  5. Conditions are evaluated by the SDK at invocation time, before the approval request is sent.
  6. Empty args_match: If args_match is 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.
  7. Empty ConditionGroup: If a ConditionGroup object is present but contains no args_match field, it is treated as { args_match: {} } and evaluates to true.
  8. 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."
  9. Regex portability: The pattern matcher 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

ContextKey FormatExample Keys
Tool/skill approval (local_tools[].approval, mcp_servers[].allowed_tools[].approval, remote_agents[].allowed_skills[].approval)Plain argument namesamount, currency, recipient_type
Delegation approval (local_agents[].approval, remote_agents[].approval)Path expressionsparent.input.risk_level
Loop exit condition (LoopConfig.exit_condition)Path expressionsquality_checker.output.score
Conditional routing (ConditionalRoute.when)Path expressionsparent.input.language