Skip to content

ROADMAP-04 — P0 — Calculator emits inf/nan into the prompt; exponent guard uses bare literals #96

Closed

Description

@getdownandcode

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:

  1. 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).
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions