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: model-conditional tool substitution (apply_patch vs edit/write) is undocumented, makes model-agnostic plugin hooks impossible #19942
Plugin hooks for file-editing operations cannot be written in a model-agnostic way because the tool that fires depends on which model is in use — and this behavior is nowhere documented.
For gpt-5 and later GPT-series models, apply_patch is substituted for edit and write. For all other models (Claude, Gemini, GPT-4o, o-series), edit and write are used. A plugin author has no way to know this without reading the source.
The substitution logic (from packages/opencode/src/tool/registry.ts)
Note: gpt-4o is not affected because it contains the substring "gpt-4".
Impact on plugin authors
There is no way to write a single model-agnostic post-edit hook today:
// Only fires for Claude/Gemini/GPT-4o — silently skipped for gpt-5 users:if(input.tool==="edit"){ ... }// Only fires for gpt-5 — silently skipped for everyone else:if(input.tool==="apply_patch"){ ... }
A plugin author must check all three names and handle them differently, but this is nowhere documented in the plugin or tools docs.
A more complete fix would be a stable abstraction — for example, a synthetic "file.edit" hook event that normalizes across edit, write, and apply_patch — so plugin authors don't need model-specific branching.
OpenCode version
1.3.6
Steps to reproduce
Write a plugin hook: if (input.tool === "edit") { /* post-edit logic */ }
Run the same file-edit task with a Claude model — hook fires correctly
Run the same task with a gpt-5-series model — hook silently never fires
No error, no warning
Verified via:
GitHub source (dev branch): src/tool/registry.ts
Compiled binary string search (v1.3.6) confirming the same logic
This issue might be a duplicate of (or closely related to) existing issues. Please check:
Bug: docs list built-in tool as patch, source registers it as apply_patch #19941: Same author, covers the apply_patch tool name mismatch in docs and undocumented args shape — the two issues overlap significantly in subject matter (plugin hooks silently failing due to apply_patch behavior). Consider whether these can be consolidated.
Activity
github-actions commentedon Mar 29, 2026
This issue might be a duplicate of (or closely related to) existing issues. Please check:
patch, source registers it asapply_patch#19941: Same author, covers theapply_patchtool name mismatch in docs and undocumented args shape — the two issues overlap significantly in subject matter (plugin hooks silently failing due toapply_patchbehavior). Consider whether these can be consolidated.github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.