Repository navigation
fix(edit_file): 前置定位模式校验并明确参数互斥规则 - #674
Merged
origami-chen merged 2 commits intoOct 20, 2026
Merged
origami-chen merged 2 commits into
origami-chen merged 2 commits into
Conversation
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.
问题与修复
edit_file原先在读取文件、查找匹配之后才检查定位参数互斥,创建文件及部分提前返回路径会绕过检查。模型参数说明也未明确定位模式和计数断言的关系。execute,在任何文件访问前拒绝冲突。occurrence、line_hint、replace_all=true的定位语义;仅replace_all=true与定位参数互斥,false可以和定位参数组合。expected_replacements保持为独立计数断言,在写入前验证选中数量;创建模式仅接受省略/null 或 1,包括无变化操作。例如,
old_text=""配合replace_all=true, occurrence=1现在直接返回参数错误,不创建文件或目录;replace_all=false, occurrence=2, expected_replacements=1可以正常替换第二处。改动范围
App/memmy-agent/src/core/agent-runtime/tools/filesystem.tsApp/memmy-agent/src/templates/agent/tool-contract.mdApp/memmy-agent/tests/core/agent-runtime/tools/edit-file-validation.test.tsApp/memmy-agent/tests/core/agent-runtime/tools/tool-descriptions.test.ts本 PR 不包含别名收敛或 exec 输出单位修复。
迁移与验证
替代原 PR #662,从上游
v1.2.6(8cd095c7)新建分支,仅 cherry-pick 原 PR 的修复提交,不携带 v1.2.4 的其他历史提交。git range-diff确认迁移前后补丁等价。git diff --check通过。合并协调
两条新 PR 均独立以 v1.2.6 为基线。修复修改相邻参数入口与工具契约,先合并一条后另一条仍需协调重叠修改;必须同时保留别名归一化与定位校验。已迁移原组合结果并通过上述联合回归。旧 PR 在新 PR 创建后可关闭,避免重复合并。