Declarative expression language for policy.where clauses
The policy expression language provides a simple, safe, and deterministic way to define access control and behavior constraints in policy.where clauses.
Minimal syntax for common use cases
No code execution or side effects
Same input always produces same result
Familiar to developers using JSON query languages
expression = comparison | logical_expr | literal
comparison = accessor operator value
logical_expr = expression logical_op expression
| "(" expression ")"
| "not" expression
accessor = identifier *("." identifier | "[" index "]")
identifier = ALPHA *(ALPHA | DIGIT | "_")
index = DIGIT+ | STRING
operator = "==" | "!=" | ">" | "<" | ">=" | "<="
| "~" | "!~" | "in" | "not in"
| "contains" | "starts_with" | "ends_with"
logical_op = "&&" | "||" | "and" | "or"
value = STRING | NUMBER | BOOLEAN | NULL | array
array = "[" [value *("," value)] "]"
STRING = "'" *CHAR "'"
NUMBER = ["-"] DIGIT+ ["." DIGIT+]
BOOLEAN = "true" | "false"
NULL = "null"| Operator | Description | Example |
|---|---|---|
== | Equality | tool.type == 'http' |
!= | Inequality | tool.type != 'system' |
> | Greater than | message.priority > 5 |
< | Less than | context.window < 8192 |
>= | Greater or equal | runtime.memory_mb_min >= 512 |
<= | Less or equal | runtime.cpu_cores_min <= 4 |
| Operator | Description | Example |
|---|---|---|
~ | Regex match | tool.endpoint ~ '^https://internal\\.corp' |
!~ | Regex non-match | tool.endpoint !~ 'external' |
contains | Substring test | message.payload contains 'urgent' |
starts_with | Prefix test | agent.id starts_with 'ajson://internal' |
ends_with | Suffix test | tool.endpoint ends_with '.internal.corp' |
| Operator | Description | Example |
|---|---|---|
in | Membership test | tool.type in ['http', 'function'] |
not in | Non-membership | tool.type not in ['system', 'plugin'] |
| Operator | Description | Example |
|---|---|---|
&& / and | Logical AND | tool.type == 'http' && tool.auth.method == 'none' |
|| / or | Logical OR | message.priority > 8 || message.urgent == true |
not | Logical NOT | not (tool.type in ['system', 'plugin']) |
From highest to lowest:
( )not==, !=, >, <, >=, <=~, !~, in, not in, contains, starts_with, ends_with&&, and||, orExpressions evaluate against a context object containing:
{
"tool": { // Current tool being invoked
"id": "...",
"type": "...",
"endpoint": "...",
...
},
"message": { // Current message envelope
"from": "...",
"to": "...",
"payload": {...},
"intent": "...",
...
},
"agent": { // Current agent manifest
"id": "...",
"name": "...",
...
},
"runtime": { // Runtime context
"environment": "production",
"timestamp": "2025-11-10T00:00:00Z",
...
}
}{
"id": "deny-http-no-auth",
"effect": "deny",
"action": "tool.call",
"where": "tool.type == 'http' && tool.auth.method == 'none'"
}Denies calls to HTTP tools that don't have authentication configured.
{
"id": "deny-external-endpoints",
"effect": "deny",
"action": "tool.call",
"where": "tool.endpoint !~ '^https://.*\\.internal\\.corp'"
}Blocks access to any endpoints outside the internal corporate domain.
{
"id": "audit-sensitive-messages",
"effect": "audit",
"action": "message.send",
"where": "(message.payload contains 'password' || message.payload contains 'api_key') && not (message.to starts_with 'ajson://internal')"
}Audits messages containing sensitive keywords being sent to external agents.
{
"id": "allow-safe-tools",
"effect": "allow",
"action": "tool.call",
"where": "tool.type in ['function', 'http'] && tool.id in ['tool://safe/search', 'tool://safe/summarize']"
}Allows only specific whitelisted tools of approved types.
falsetrue > false)nullnull == null evaluates to truenull compared to any non-null value evaluates to false&&: If left operand is false, right operand is not evaluated||: If left operand is true, right operand is not evaluatedlength(), upper(), lower()map(), filter()before, afterexists, forallRead the complete policy expression language specification in Appendix B
View Full SpecificationContinue exploring JSON AGENTS
Read the complete JSON Agents specification including the Gov profile with policy definitions
Learn how to implement and evaluate policy expressions in your agent runtime environment
Explore governance profile examples with real-world policy rules and access control patterns
Quick introduction to JSON Agents including basic policy configuration examples