Skip to content

apply_patch rewrites unrelated lines in Python files for single-line edits #15864

@JDNdeveloper

Description

@JDNdeveloper

Description

Using apply_patch to make a one-line docstring change in a Python file can also rewrite unrelated lines in the same file. I consistently see extra formatting changes such as quote normalization (' to ") even when only one line is targeted.

Plugins

None

OpenCode version

1.2.15

Steps to reproduce

  1. Create a file named repro.py:
def a():
    """x"""
    return 'y'
  1. Apply this patch to repro.py (ask the agent to update "x" to "x updated"):
*** Begin Patch
*** Update File: /absolute/path/to/repro.py
@@
-    """x"""
+    """x updated"""
*** End Patch
  1. Inspect repro.py after patch. It becomes:
def a():
    """x updated"""
    return "y"

Note the edit to return "y".

Screenshot and/or share link

No response

Operating System

Windows 11 WSL

Terminal

Windows Terminal

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)windows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions