Repository navigation
fix: drop toLocaleString() thousands separators from LLM-facing tool output - #773
Merged
will-lamerton merged 2 commits intoAug 5, 2026
Merged
Conversation
…output toLocaleString() was used on numbers in strings returned to the model (read_file's metadata/output paths, its minified-content validator error, list_directory's per-entry size, and file-content-loader's @file-mention metadata), not just in display components. Comma separators cost extra tokens and carry no meaning for the model. Left toLocaleString() untouched everywhere it belongs: the Ink `<Text>` formatter components (read-file.tsx, list-directory.tsx, search-file-contents.tsx, find-files.tsx) and the chat-queue-only compaction/context messages (compact-handler.ts, context-max-handler.ts, auto-compact.ts), which never reach the model. Updated the one existing test that asserted the old comma-formatted output (read-file.spec.tsx's minified-content validator test). Fixes Nano-Collective#768
MsfPablo
requested review from
Avtrkrb,
akramcodez and
will-lamerton
as code owners
August 3, 2026 16:17
akramcodez
reviewed
Aug 4, 2026
akramcodez
left a comment
Member
There was a problem hiding this comment.
LGTM another great PR @MsfPablo
Member
|
Thanks for this PR @MsfPablo - feel free to add yourself as a contributor to our website via a PR which I will approve :) https://nanocollective.org/contributors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #768.
toLocaleString()was leaking comma thousands-separators into strings returned to the model as tool results, not just into the terminal display. Comma separators cost extra tokens and carry no meaning for the model — this was flagged as good-first-issue material by the maintainer.Fixed the LLM-facing (
execute/validator) paths:source/tools/read-file.tsx— metadata output (size, lines, tokens), large-file metadata output, and the minified/binary-content validator error messagesource/tools/list-directory.tsx— per-entry byte size in the directory listingsource/utils/file-content-loader.ts— binary-file and large-file metadata shown when a file is loaded via@filemention (this content is inlined into the chat message sent to the model)Left
toLocaleString()in place everywhere it's actually display-only, per the issue's own guidance (Formattercomponents vsexecutefunctions):<Text>formatter components inread-file.tsx,list-directory.tsx,search-file-contents.tsx,find-files.tsx— these render to the terminal, never to the modelcompact-handler.ts,context-max-handler.ts,auto-compact.ts— checked these too since they also format token counts, but their formatted strings only go toonAddToChatQueue(local terminal display); the actual conversation array passed to the model (setMessages(...)) doesn't include them, so they're out of scopeTest plan
pnpm run test:format,test:lint,test:types— all cleanpnpm run test:avaon the three affected spec files — 84 tests passread-file.spec.tsx, minified-content validator) asserted the old comma-formatted output (/15,000 characters/); updated it to match the fixed output (/15000 characters/) since that was testing the exact behavior this issue asks to remove