Skip to content

fix(tools): stop prefixing edit tool responses with line numbers - #790

Open
Pixie-19 wants to merge 2 commits into
Nano-Collective:mainfrom
Pixie-19:fix/remove-line-number-prefixes
Open

fix(tools): stop prefixing edit tool responses with line numbers#790
Pixie-19 wants to merge 2 commits into
Nano-Collective:mainfrom
Pixie-19:fix/remove-line-number-prefixes

Conversation

@Pixie-19

@Pixie-19 Pixie-19 commented Aug 4, 2026

Copy link
Copy Markdown

Description

Fixes #765.

This PR removes line-number prefixes from the responses returned by the string_replace and write_file tools.

Previously these tools returned file contents like:

1: import ...
2: const x = ...

while read_file returned raw file contents without numbered prefixes. This inconsistency could cause follow-up edits to fail because string_replace expects the exact file contents.

The tools now return the raw file contents, making their output consistent with read_file.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • Existing TypeScript compilation passes (npm run test:types)
  • Biome lint and format checks run successfully (schema version warning only)

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No breaking changes

@Pixie-19
Pixie-19 requested a review from will-lamerton as a code owner August 4, 2026 17:50
Copilot AI lite review requested due to automatic review settings August 4, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an inconsistency between read_file and the edit tools (write_file, string_replace) by removing per-line line-number prefixes from the file contents those edit tools return. This makes follow-up content-based edits (especially string_replace, which requires exact matches) less likely to fail due to formatting differences introduced by tool output.

Changes:

  • Update write_file to return the post-write file contents without per-line line numbers.
  • Update string_replace to return the updated file contents without per-line line numbers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
source/tools/file-ops/write-file.tsx Removes the %4d: prefixing loop and returns the raw post-write file contents.
source/tools/file-ops/string-replace.tsx Removes the %4d: prefixing loop and returns the raw updated file contents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edit tools return line-number prefixes while read_file strips them

2 participants