logoCaywork Knowledge

Calculator Local Tool Node

Secure, sandboxed evaluator that supports a defined set of mathematical operators, functions, and constants.

Calculator Local Tool Node image

This node evaluates arithmetic and mathematical expressions safely using a restricted AST interpreter. It accepts a single expression or a list of expressions and returns structured results for each.

Actions (Mathematical features)

  • Arithmetic operators: +, -, *, /, %, // (floor division), ** (power)
  • Unary operators: +, -
  • Bitwise operators: &, |, ^, <<, >>
  • Math functions: sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, exp, log, log10, sqrt, abs, round, floor, ceil, factorial, pow
  • Constants: pi, e, tau, inf, nan
  • Tuples: construction of tuples of supported expressions (e.g., "(1, 2+3)")

Unsupported / Forbidden Mathematical Constructs

  • Matrix multiplication operator (@) — disallowed
  • Function calls other than the listed math functions
  • Keyword arguments to functions
  • Variables/identifiers other than the listed constants
  • Complex numbers (not supported unless expressed via allowed functions/constants)
  • Results with absolute value > 1e100 — rejected as too large

Inputs and configuration (brief)

  • expr: string or list of strings — expression(s) to evaluate (caret ^ rewrites to **).
  • max_nodes: per-expression AST node limit.
  • timeout: per-expression timeout in seconds.

Output (brief)

  • results: array of objects per input with fields: input, result (or null), error (or null), meta (includes execution time).