Repository navigation
fix(session): fire tool.execute.after hook after MCP output assembly - #21150
Closed
YumaKakuya wants to merge 1 commit into
Closed
YumaKakuya wants to merge 1 commit into
YumaKakuya wants to merge 1 commit into
Conversation
The tool.execute.after hook fires for MCP tools before the output text
is assembled from the raw CallToolResult.content[] array. Plugins
receive the raw SDK result instead of the {title, output, metadata}
shape declared in the Hooks type definition.
Any plugin that transforms output.output (e.g. masking sensitive data)
has no effect because:
1. The output property does not exist on the raw result at hook time
2. The text assembly at L502-536 rebuilds output from result.content
independently of any hook mutations
This moves the trigger call to after text assembly and truncation,
passing an assembled object that matches the declared type contract.
The return statement references the assembled object so plugin
mutations are reflected in the final tool output.
Closes #21149
Collaborator
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
11 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 #21149
Type of change
What does this PR do?
tool.execute.afterfires for MCP tools before the output text is assembled from the rawCallToolResult.content[]array. Plugins receive the raw SDK result instead of the{title, output, metadata}shape declared in theHookstype definition.Any plugin that tries to transform
output.outputgetsundefined, and the text assembly at L502-536 rebuilds the output fromresult.contentindependently of any hook mutations. The hook is effectively a no-op for MCP tool output transformation.This moves the trigger call to after text assembly and truncation, passing an
assembledobject that matches the declared type contract. The return statement references the assembled object so plugin mutations are reflected in the final tool output.How did you verify your code works?
npm-package-argerror inshared.tsis pre-existing on dev)prompt.ts. Native tools (bash, read, etc.) are unaffected — they have their own hook pathsHookstype definition inpackages/plugin/src/index.tsScreenshots / recordings
N/A — no UI change.
Checklist