fix(opencode): propagate tool.definition hook parameter modifications to MCP tools#31685
Open
davidgut1982 wants to merge 3 commits into
Open
fix(opencode): propagate tool.definition hook parameter modifications to MCP tools#31685davidgut1982 wants to merge 3 commits into
davidgut1982 wants to merge 3 commits into
Conversation
Add 2 unit tests proving the fix at session/tools.ts lines 120-123: - Hook fires with correct toolID and description - Plugin mutation of description propagates to returned tool Uses Layer.mock for MCP and ToolRegistry services, Layer.succeed for Plugin.Service with captured hook calls.
- Replace Layer.succeed for Truncate.Service with Layer.mock (Truncate.Interface has no 'init' method) - Add mandatory 'mode' and 'options' fields to test agent objects
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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 #31677
Type of change
What does this PR do?
The
tool.definitionhook insession/tools.tswas passing a{description}object to plugins, but only reading back the description. Any modifications plugins made toparameters(the input schema) were silently dropped — the original MCP tool's schema was used instead.This fix adds
item.inputSchema = defOutput.parametersso the plugin's parameter modifications actually propagate to the final tool registration. Without this, the MCP router plugin's parameter-stripping hook (and any future schema-modifying plugins) would have no effect on MCP tools.How did you verify your code works?
bun test tool/tool-definition-mcp.test.ts— 3/3 tests pass, 9 expect() calls, 0 failuresoutput.parametersto add amodifiedboolean property, then verifies the schema change appears on the resolved toolScreenshots / recordings
N/A — no UI changes.
Checklist