positron icon indicating copy to clipboard operation
positron copied to clipboard

[EPIC] Assistant: `editFile` tool

Open simonpcouch opened this issue 3 weeks ago • 2 comments

I'm struggling to get PA to edit files. Here's a screencast of adding a line to a text file (with today's daily):

https://github.com/user-attachments/assets/7a285eb7-1355-4860-98c4-9b5898b835d8

A few observations here:

  1. A reasonable edit is shown inline in a reasonable amount of time! I would expect the UI to appear instantly after the tool is invoked, but the current latency to first seeing the comment appear in the editor is workable.
  2. After the first edit is applied, and before I have a chance to review it, the tool returns (and with a "Success" result that indicates an error in its contents). In the logs, after each tool request, I see:
          "content": [
           {
             "type": "text",
             "text": "Error invoking tool positron_editFile_internal."
           },
           {
             "type": "text",
             "text": "Unexpected end of JSON input"
           }
         ]

At the point, the agent keeps trying to call the tool with more-and-more far-fetched approaches, until I stop execution.

  1. Line 9, with the tryCatch(), is highlighted for a while before the actual suggestion appears.
  2. The "Applying edits" percentage decreases from 11% to 6%, seemingly after the first edit has been applied, and persists for a while. I don't know that we should need that "Applying edits" dialog at all; with a str_replace() based edit, we should be able to display that diff instantly.

System details:

Positron and OS details:

Positron Version: 2025.12.0 build 72 Code - OSS Version: 1.105.0 Commit: 3af147dca07686d2cfa80faf0796c04661c56616 Date: 2025-11-14T07:19:22.022Z Electron: 37.6.0 Chromium: 138.0.7204.251 Node.js: 22.19.0 V8: 13.8.258.32-electron.0 OS: Darwin arm64 24.6.0

Session details:

Claude 4.5 Sonnet.

Describe the issue:

Steps to reproduce the issue:

  1. Open a text file with many lines
  2. Ask to add a specific comment to a specific line

Expected or desired behavior:

I would expect, with this prompt:

  1. A file read
  2. The editFile to be called successfully once, at which point 2a) The approval UI is "un-greyed out" immediately with the proposed edit. 2b) Only when I Reject or Approve does the tool return to the model. If I approve, a tool result success indicates that the edit was approved. If I reject, control is not deferred back to the model, and instead ghost/placeholder text prompts me to provide suggestions to the agent. When I submit, the tool result says "The user rejected the edit with the following feedback: {my_user_message}"

Were there any error messages in the UI, Output panel, or Developer Tools console?

Trace-level assistant traces:

assistant-file-edit.log

simonpcouch avatar Nov 19 '25 16:11 simonpcouch

Ah, one more note on expected behavior: if the model proposes a file edit and it wouldn't be able to be applied even if the user approved it (e.g. if there's no old_str match), the tool should fail without looping in the user or triggering the file edit UI.

simonpcouch avatar Nov 19 '25 16:11 simonpcouch

I think it probably makes sense to treat this as an epic—will open a few issues and link them here shortly!

simonpcouch avatar Nov 19 '25 22:11 simonpcouch