math.evaluate
Schema
Input = { expression: string, // a mathjs expression, e.g. "sqrt(3^2 + 4^2)" or "derivative('x^2', 'x')" scope?: Record<string, number | string | boolean>, // named variables precision?: number, // 1-64, default 14}
Output = { result: string, // formatted at the requested precision value: number | string | boolean | null, type: string, // mathjs type, e.g. "number", "BigNumber", "Unit"}Every agent has this by default (DEFAULT_AGENT_SKILLS) specifically so a model never has to do
mental arithmetic — a common source of small, avoidable errors. It runs on a hardened mathjs
instance (packages/skills/src/core/math.ts): import, createUnit, evaluate, parse,
resolve, and compile are all disabled on the instance, mirroring mathjs’s own documented
“secure eval” recipe, so an expression can compute but never redefine the sandbox or nest another
evaluator inside itself.
Example
curl -s -X POST http://localhost:4000/api/studio/skills/invoke \ -H 'content-type: application/json' -b cookies.txt \ -d '{"name":"math.evaluate","input":{"expression":"5000 * (1 + 0.08)^3","precision":6}}'{ "ok": true, "output": { "result": "6298.56", "value": 6298.56, "type": "number" } }This is the exact mechanism behind the Business plan generator’s financial-projections step and the Data analysis generator’s profiling step, both of which are instructed to compute real numbers with this skill rather than stating an estimate as if it were arithmetic.