oc_edit / oc_write not registered in tool hook despite system prompt instructing model to use them
Summary
In CURSOR_ACP_TOOL_LOOP_MODE=opencode (default), the plugin system prompt tells the model to call tools as oc_edit, oc_write, etc., but buildToolHookEntries() only registers unprefixed names (edit, write, …).
bash already has a shell alias; edit/write/etc. do not have matching oc_* aliases.
Result: with cursor-acp/auto, the model calls oc_edit and the tool fails or retries in a loop.
Environment
@rama_nigg/open-cursor: 2.4.6- OpenCode with plugin
cursor-acp - Model:
cursor-acp/auto - OS: macOS
CURSOR_ACP_TOOL_LOOP_MODE: default (opencode)
Steps to reproduce
- Install and configure open-cursor per README
- Run OpenCode with model
cursor-acp/auto - Ask the agent to edit a file with a small targeted change
- Observe tool calls to
oc_edit(or retries / "tool not found" behavior)
Expected
oc_edit resolves to the same handler as edit (same pattern as bash → shell).
Actual
Only edit is registered in the tool hook. The model follows the injected system message and calls oc_edit, which is missing.
Root cause
buildAvailableToolsSystemMessage()advertisesoc_${id}names (viarefreshTools()in proxy-exec path)buildToolHookEntries()registers onlyt.name, notoc_${t.id}TOOL_NAME_ALIASESintool-loop.tshas bash/shell aliases but noocedit→edit
Proposed fix
- In
buildToolHookEntries(), registeroc_${t.id}for each local tool - In
TOOL_NAME_ALIASES, addocedit→edit,ocwrite→write, etc.
Happy to open a PR if useful.
Thanks bud, will look at this properly Saturday (getting blasted at work this week which is just eating my open source / hobby time).
same issue here. Any attempt to edit any file with OpenCode+Cursor(OpenCursor) erases the whole file and only keeps the modified lines
Thanks mate, you were right here.
I’ve merged a fix to main in 277a8d8. The original oc_edit issue was fixed by registering the oc_* tool aliases, but that exposed an older bad edge case in the local edit executor: if a model sent old_string as an empty string, the edit tool treated that as a whole-file overwrite. That explains the “file gets erased and only keeps the modified lines” behaviour.
cheers, RAMA
Thank you !!!! I assume this fix made it into 2.4.9 ?
just tested on 2.4.9 and looks like the issue is still there. how to verify:
- update
open-cursorto latest version:
npm update -g @rama_nigg/open-cursor
- run opencode, use one of cursor models (e.g.
composer 2.5) and execute a simple text editing task:
create test.txt, fill it with numbers 1..100
save to disk
then change line 50 to "test test"
save to disk
then remove one of "test" so that there are no duplicates
Result:
Yep oc_edit path and the empty old_string case, but composer can also send an edit payload with content / streamContent and no old_string. In that shape, opencode could still treat a tiny changed fragment as a full-file edit, which is why the file ended up getting cut down to just a few lines.
Cursor designs everything IDE-first which causes a lot issues downstream and makes its a real bastard to keep working... hopefully this fix works, if not will keep this one open and hopefully others have suggestions.
Triage (2026-06-18): Keeping open as bug.
oc_*hook aliases shipped in v2.4.7+ (commit 88ba152)- Follow-up guards for Composer
content/streamContentedit payloads shipped in v2.4.10–v2.4.11 (emptyold_string/ partial overwrite protection)
Latest report still reproduces on 2.4.9 — please retest on >= 2.4.11 and share whether the line-50 edit case is resolved. If not, we'll keep tracking the Composer IDE-first payload shape here.
updated. retested. still fails. the agent enters an infinite loop trying to edit a single line of text and never completes.
nes 1–100, then updating line 50.
~ Preparing edit...
Thought: 8.0s
Proceeding with the task.
Write
Thought: 1.9s
The previous write attempt was refused because it would partially overwrite an existing file. I will use edit with old_string and new_string instead, or pass force: true if I intend to replace the entire file.
~ Reading file...
Thought: 4.6s
The first step is complete. I am now reviewing the remaining tasks.
Line 50 already contains "test test". The file appears corrupted. I am reading the full file to assess its current state.
Checking the file state and finishing the remaining edits.
~ Reading file...
Thought: 1.1s
Proceeding with the task.
Write
Thought: 10.4s
The write tool refused a partial overwrite of test.txt. I'll use edit with old_string and new_string instead.
Write
Thought: 1.2s
The write tool refused to overwrite the existing file test.txt because it would reduce 100 lines to 1. I will use edit with old_string and new_string instead, or pass force: true if intentional.
Write
Thought: 222ms
The write tool refused to overwrite test.txt because the new content is much smaller than the existing file. I will use edit instead to replace only the necessary portion.
Write
Thought: 854ms
I need to complete the task on test.txt.
Write
Thought: 2.2s
The user wants me to complete the task on test.txt.
Write
Thought: 1.1s
The write operation was refused because it would partially overwrite an existing file. I'll use edit with old_string and new_string instead, or pass force: true if intentional full replacement is needed.
Write
Thought: 1.1s
The previous write attempt was refused due to a suspicious partial overwrite. I will retry with a targeted edit or full replacement.
Write
Thought: 2.1s
The user wants me to continue the task from the previous conversation.
Write
Thought: 1.9s
The user wants me to complete the task.
Write
Thought: 2.3s
The user wants me to continue the task.
Write
Thought: 1.8s
The previous write operation was refused because it would partially overwrite an existing file. I will proceed by using edit with old_string and new_string instead, or by passing force: true if intentional full replacement is needed.
Write
Thought: 2.2s
The user wants me to continue the task from the previous conversation. I'm reviewing the context to determine the next step.
Line 50 is now "test test". I'll use edit/strreplace to remove one duplicate "test" from that line.
Write
Thought: 848ms
The first step is already done. The next steps are being reviewed.
Write
The user wants me to complete the task on test.txt.