-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: Add multi-file apply_diff support for native protocol #10104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Create multi_apply_diff.ts schema with files array parameter - Add createApplyDiffTool factory function to swap schemas based on experiment flag - Update getNativeTools to accept multiFileApplyDiffEnabled parameter - Update NativeToolCallParser to handle both single-file and multi-file formats - Update presentAssistantMessage to route based on nativeArgs format - Update MultiApplyDiffTool to handle nativeArgs.files array - Update NativeToolArgs type to union type supporting both formats - Add 8 tests for apply_diff parsing in both formats
Re-review complete. Native multi-file
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| | { path: string; diff: string } | ||
| | undefined | ||
|
|
||
| if (nativeArgs && "files" in nativeArgs && Array.isArray(nativeArgs.files)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In native mode, multi-file apply_diff routes via nativeArgs.files, but the mode fileRegex restrictions are currently enforced via validateToolUse(block.params). Since params may not include a single path (and validateToolUse does not parse the JSON-encoded params.files), this can bypass file restrictions for multi-file native apply_diff. Consider validating each entry in nativeArgs.files (or passing a normalized {path/args} into validation) before dispatching to MultiApplyDiffTool.
Fix it with Roo Code or mention @roomote and request a fix.
…pply_diff Addresses review feedback to ensure multi-file native apply_diff (nativeArgs.files) cannot bypass mode fileRegex restrictions. Changes: - Added nativeArgs parameter to validateToolUse and isToolAllowedForMode - Added validation for nativeArgs.files (multi-file format) paths - Added validation for nativeArgs.path (single-file format) paths - Pass block.nativeArgs to validateToolUse in presentAssistantMessage - Added comprehensive test coverage for native protocol file restrictions
Summary
Adds support for multi-file
apply_diffbatching when using native protocol (OpenAI-style function calling), controlled by theMULTI_FILE_APPLY_DIFFexperiment flag.Problem
The
apply_difftool currently only supports multi-file batching with XML protocol. When native protocol is enabled, it bypasses multi-file logic and uses single-fileApplyDiffToolonly.Solution
Two separate schemas are swapped based on the
MULTI_FILE_APPLY_DIFFexperiment flag:apply_diff.ts):{ path: string, diff: string }multi_apply_diff.ts):{ files: [{ path, diff }] }A factory function
createApplyDiffTool(multiFileEnabled)selects the appropriate schema.Files Modified
src/core/prompts/tools/native-tools/multi_apply_diff.ts- NEW: Multi-file schema definitionsrc/core/prompts/tools/native-tools/apply_diff.ts- Added factory functionsrc/core/prompts/tools/native-tools/index.ts- UpdatedgetNativeTools()to accept experiment flagsrc/core/task/build-tools.ts- Pass experiment flag togetNativeTools()src/shared/tools.ts- UpdatedNativeToolArgs.apply_diffto union typesrc/core/assistant-message/NativeToolCallParser.ts- Handle both formats in parsingsrc/core/assistant-message/presentAssistantMessage.ts- Routing based onnativeArgsformatsrc/core/tools/MultiApplyDiffTool.ts- HandlenativeArgs.filesformatTest Coverage
NativeToolCallParser.spec.tsfor both native formatsapplyDiffTool.experiment.spec.tsto reflect new routing architectureTesting
All 4,728 tests pass.
Important
Adds multi-file
apply_diffsupport for native protocol with schema selection and routing based onnativeArgs, controlled by an experiment flag.apply_diffsupport for native protocol, controlled byMULTI_FILE_APPLY_DIFFflag.createApplyDiffTool()to select between single-file and multi-file schemas.presentAssistantMessage()to route based onnativeArgsformat.multi_apply_diff.ts.apply_diff.tsto include factory function for schema selection.NativeToolCallParser.ts: Parses both single-file and multi-file formats.build-tools.ts: Passes experiment flag togetNativeTools().validateToolUse.ts: Validates file restrictions for both formats.NativeToolCallParser.spec.tsfor both formats.applyDiffTool.experiment.spec.tsfor new routing logic.NativeToolArgs.apply_diffto a union type intools.ts.This description was created by
for 725d25d. You can customize this summary. It will automatically update as commits are pushed.