Repository navigation
refactor(codemode): before/after hooks for tool and extension calls - #49242
Merged
Merged
Conversation
rekram1-node
force-pushed
the
call-hook
branch
4 times, most recently
from
September 16, 2026 03:05
a6e848b to
b3972af
Compare
rekram1-node
force-pushed
the
call-hook
branch
2 times, most recently
from
September 16, 2026 03:12
a489d1f to
4eba358
Compare
rekram1-node
force-pushed
the
call-hook
branch
from
September 16, 2026 03:53
4eba358 to
5e04086
Compare
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hooks around every call the program makes into the host — tools and extension globals — named after the two things a host registers. They replace
onToolCallStart/onToolCallEnd, which only fit tools, needed anindexto pair up, and could not deny.Same shape as the plugin API's
execute.before/execute.after.afterobserves and cannot change the result. The samecallobject reachesbeforeandafter, so a host pairs them by identity with no index. Functions inside an extension result (res.json()) are part of a value's API and do not fire hooks.result.toolCallsandmaxToolCallsare unchanged and still count tools only; a denied tool call was still admitted, so it appears in both.Core
The only consumer migrates here.
progressHooks(record)appends a running row inbeforeand settles it inafter, keyed by aWeakMapfrom the call object to its row.Once #49235 (fetch) lands on top, fetch requests show under
executein the TUI with no further plumbing.Checks
packages/codemodebun test5123 pass / 0 fail. Hook tests cover tools and extensions, denial from eitherbefore, a tool defect and an interrupted extension call as seen byafter, every previous interruption case, and error location on a bad extension result (parity with other built-in errors).packages/coretest/tool-execute.test.ts+test/codemode27 pass; existingtoolCallsmetadata assertion unchanged.bun run check35/35.