fix: Allow plugin hooks to mutate tool call args before context creation#20053
Open
yejiming wants to merge 1 commit intoanomalyco:devfrom
Open
fix: Allow plugin hooks to mutate tool call args before context creation#20053yejiming wants to merge 1 commit intoanomalyco:devfrom
yejiming wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
This PR appears to be addressing the same issue as #20053. Both are about allowing tool execution hooks (specifically You should verify whether #20009 was already merged or if it's still open, as it may render the current PR redundant. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
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.
Issue for this PR
Closes #20013
Type of change
What does this PR do?
tool.execute.beforehooks receive{ args }, but tool execution continued with the originalargsreference captured before the hook ran. That meant hooks could mutateoutput.argswithout affecting the actual tool call.This change routes both native tools and MCP tools through a mutable
out = { args }object, triggers the before hook with that object, and then executes tools usingout.args. It also passesout.argstotool.execute.afterfor consistency.Why this works: the before hook can now replace or inject args by mutating the shared
out.argsobject, and the execution path reads from the same object after the hook completes.How did you verify your code works?
bun test test/plugin/trigger.test.tsinpackages/opencode(environment warning: missing preload module@opentui/solid/preload).bun typecheckinpackages/opencode(environment warning:tsgonot available in this container).Screenshots / recordings
Not a UI change
Checklist