You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Edit tool silently deletes symbol definitions without cross-reference validation #33062
The edit tool (packages/core/src/tool/edit.ts) performs exact text replacement via source.text.replace(oldString, newString) with only 4 validations (L165-L176):
oldString !== newString (tool level)
oldString is not empty (tool level)
oldString exists in file (L165)
Single match when replaceAll is not set (L171)
It does NOT check whether the removed text region contains symbol definitions referenced elsewhere. After replacement succeeds, no cross-reference scan verifies remaining code integrity.
Real case: editing a Python file with three consecutive class methods. The model replaced the block covering all three with a newString containing only two methods. The third method (used in __init__ via QShortcut binding) was silently dropped. The edit tool returned success. py_compile passed. Runtime crash: AttributeError.
Steps to reproduce
Open a Python file with three consecutive function definitions at the same indent level, where the last function is referenced earlier in the same file (e.g., __init__ binds a shortcut to _toggle_pause)
Ask the model to "refactor these three methods into two"
The model produces an edit call where oldString spans all three method definitions, but newString omits the last method
The edit tool matches oldString exactly and applies newString (L178-L181)
The third function is silently removed
py_compile passes (no syntax error since the resulting file is well-formed)
The user runs the program → AttributeError at runtime because the deleted method is still referenced
Expected behavior
The edit tool should validate that the removed region does not contain symbol definitions still referenced elsewhere in the file before applying the replacement. This requires a post-hoc scan of the new file content for remaining references.
Activity
rekram1-node commentedon Jun 22, 2026
STOP SPAMMING ISSUES.