You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ROADMAP-04 — P0 — Calculator emits inf/nan into the prompt; exponent guard uses bare literals #96
Series:ROADMAP — filed from the 2026-10-27 whole-project assessment · Backlog task: M14-T04 · Priority: P0 · Effort: extra small
Problem
Two related nits in the otherwise well-bounded AST calculator:
Float results are never checked with math.isfinite, so overflow paths like 1e308 * 10**3 produce inf/nan strings that flow into the prompt (and into history).
The exponent-blast-radius guard at line 59 hardcodes bare literals 1000 / 100 instead of referencing MAX_EXPONENT, so a future change to the constant desynchronizes it.
Evidence
agentkit/tools/builtin/calculator.py:59 — abs(left) > 1000 and right > 100 bare constants
agentkit/tools/builtin/calculator.py:14, 66–74 — existing MAX_RESULT_BITS / integer blast-radius guards to model the fix on
Suggested fix / acceptance criteria
Non-finite float results (and intermediate values) produce a structured ToolResult(ok=False, error=...), never inf/nan text
Exponent guard constants reference MAX_EXPONENT (or a derived bound); behaviour unchanged at current values
Unit tests for 1e308 * 10**3, 0 ** 0-edge and deep-division paths
Suggested branch / commit
fix/calculator-finite-guard · fix(tools): reject non-finite calculator results and tie exponent guard to MAX_EXPONENT
Activity