expr
Evaluate arithmetic and string expressions in a safe, side-effect-free AST subset. Use for calculations and conditional logic in agent workflows.
Instructions
Evaluate arithmetic and string expressions in a safe, side-effect-free AST subset. Read-only, no side effects. Supports +, -, *, /, % (arithmetic), comparisons, regex matching, and string operations. Returns JSON with the computed result. Use for calculations and conditional logic in agent workflows. Not for file-based predicate tests — use 'test' or '[' for path checks. See also 'test', 'factor'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exit_code | No | Return exit code 1 when the result is false/zero/empty. | |
| raw | No | Write the expression value without a JSON envelope. | |
| tokens | Yes | Expression tokens, for example: 1 + 2 or 3 '>' 2. |