Skip to content

toLocaleString() thousands separators leak into LLM-facing tool results #768

Closed

Description

@will-lamerton

Problem

toLocaleString() is used when building strings that go into tool results, not just display output. Examples:

  • source/tools/read-file.tsx:53 Size: ${size.toLocaleString()} bytes
  • source/tools/read-file.tsx:66-67 line count and estimated tokens
  • source/tools/read-file.tsx:133-135 the metadata response
  • source/tools/list-directory.tsx:162 per-entry byte sizes

12,345 costs more tokens than 12345 and carries no additional meaning for a model. Thousands separators are a human-readability affordance.

This is correct for the Ink display layer, which is why the pattern exists. It is just wrong on the path that feeds the LLM.

Fix

Use plain numbers in any string returned from a tool execute, and keep toLocaleString() in the formatter components that render to the terminal.

Worth a quick grep for other instances beyond the ones listed, since the two paths are easy to confuse. The distinction to apply: anything inside a Formatter React component is display and should stay; anything inside an execute function is LLM payload and should not.

Notes for a first-time contributor

Mechanical and low-risk, but it does require care to only change the LLM-facing path and leave the display path alone. Good way to get familiar with how nanocoder separates tool execution from tool rendering.

Activity

  1. will-lamerton commented on Aug 3, 2026

    @will-lamerton
    MemberAuthor

    Part of #772.

  2. Dashetty commented on Aug 3, 2026

    @Dashetty

    Hello there, I'd like to work on this.

  3. added a commit that references this issue on Aug 5, 2026
    3231582
  4. added
    area:providers
    on Oct 7, 2026
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

    area:providersclean upgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions