Field Reference
Fields extract values from tool call inputs for condition matching.
Built-in fields
command
Resolves to input.command. Used for Bash/shell tool calls.
IF command CONTAINS "rm -rf"
path
Resolves to input.file_path or input.path (tries both). Used for file operations.
IF path ENDS_WITH ".env"
IF path GLOB "src/**/*.ts"
content
Resolves to input.content or input.new_string (tries both). Used for write/edit operations.
IF content LINE_CONTAINS "console.log"
IF content REGEX "@ts-ignore"
tool
Resolves to the tool name itself (e.g., "Bash", "Read", "Write", "Agent").
IF tool EQUALS "Bash"
IF tool NOT EQUALS "Read"
Generic input fields
Access any key in the tool input object using input.<key> syntax:
IF input.subagent_type EQUALS "Explore"
IF input.run_in_background EQUALS "true"
IF input.description CONTAINS "delete"
IF input.file_path GLOB "*.secret"
Behavior
- String values are used as-is
- Non-string values (numbers, booleans, objects, arrays) are JSON-stringified before matching
- Missing keys resolve to empty string — positive conditions won't match,
NOTconditions will match - Null values resolve to empty string
Examples
Given tool call:
{
"tool": "Agent",
"input": {
"subagent_type": "Explore",
"run_in_background": true,
"prompt": "Find all TypeScript files"
}
}
| Field | Resolves to |
|---|---|
input.subagent_type | "Explore" |
input.run_in_background | "true" (JSON-stringified) |
input.prompt | "Find all TypeScript files" |
input.nonexistent | "" (empty string) |
Use cases
Audit agent activity by type:
rule log-explore-agents {
enabled true
LOG agent
IF input.subagent_type EQUALS "Explore"
MESSAGE "Explore agent activity logged."
}
Block background agents:
rule no-background-agents {
enabled true
DENY agent
IF input.run_in_background EQUALS "true"
MESSAGE "Background agents are not allowed."
}
Restrict agent models:
rule no-haiku-agents {
enabled true
DENY agent
IF input.model EQUALS "haiku"
MESSAGE "Only sonnet and opus models allowed for agents."
}
Size operators
Four operators measure the byte or token length of any field value instead of matching its content. They work on built-in fields (command, path, content, tool) and on input.<key> custom fields.
| Operator | Matches when |
|---|---|
LENGTH_GT N | UTF-8 byte length of the field value is strictly greater than N |
LENGTH_LT N | UTF-8 byte length of the field value is strictly less than N |
TOKENS_GT N | Estimated token count (byte_length / 4) is strictly greater than N |
TOKENS_LT N | Estimated token count (byte_length / 4) is strictly less than N |
The RHS value must be a decimal integer. A non-numeric RHS never matches — the operator fails open and cannot cause a spurious block.
Token estimation uses integer division of the UTF-8 byte length by 4, matching the deterministic ~4 chars/token heuristic used by the shipped Go engine (go/internal/goengine/matcher.go sizeCompare).
Cap large write payloads:
rule no-giant-writes {
enabled true
DENY write
IF content LENGTH_GT "102400"
MESSAGE "Write payload exceeds 100 KB limit."
}
Warn on long prompts to sub-agents:
rule log-large-agent-prompts {
enabled true
LOG agent
IF input.prompt TOKENS_GT "2000"
MESSAGE "Agent prompt exceeds 2000 estimated tokens."
}