fix: ctx_patch batch ops rejected with -32602 (schema over-constrains top-level path) (#1005)#1007
Closed
andig wants to merge 2 commits into
Closed
fix: ctx_patch batch ops rejected with -32602 (schema over-constrains top-level path) (#1005)#1007andig wants to merge 2 commits into
andig wants to merge 2 commits into
Conversation
…path (yvgude#1005) ctx_patch rejected valid batch calls with `-32602: path is required`. The schema declared `required: ["path"]` and the handler called require_resolved_path unconditionally, so a documented batch (`ops:[{op, path, ...}]`) was refused before execution. The impl also only ever applied ops to one shared `params.path`, so the advertised cross-file batch never actually worked. Fixes: - Schema: drop `path` from `required`; top-level `path` is optional when `ops` is present. - Handler: `plan_groups` groups batch ops by each op's own `path` (falling back to the top-level `path`), resolves+write-gates each file, and applies them per file via the shared `apply_one` (extracted from the old inline body, reused by the single-op path too). A batch may now span files. Also softens ctx_read's `mode` docs, which overclaimed "REQUIRED" though the param is optional and defaults to auto (yvgude#1005 item 2). Item 3 (modeling action-conditional requirements across ctx_execute / ctx_search with oneOf/if-then) is left as a follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The verbose `ops` schema description pushed ctx_patch to 389 tok, over the 370-tok per-tool core budget (core_tool_surface_stays_within_budget). Move the per-op-path note into the main description and drop the redundant `ops` description — ctx_patch is back to 355 tok. Regenerate the schema-derived reference docs (docs/reference/generated/mcp-tools.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
|
Superseded by and integrated into #1013, including per-op cross-file batch planning, schema correction, token-budget protection, and additional regression coverage. The original commit/authorship remains preserved in the integrated history. Thank you. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
Fixes #1005.
ctx_patchrejected valid batch calls withMCP error -32602: path is required. The tool documentsBatch: ops:[{op, path, ...}], but:required: ["path"], andrequire_resolved_path(…, "path")unconditionally,so a correct batch was refused before it ever reached execution. On top of that, the implementation only applied ops to one shared
params.path— the advertised cross-file batch never actually worked.Fix
pathfromrequired. Top-levelpathis optional whenopsis present.plan_groupsgroups batch ops by each op's ownpath(falling back to the top-levelpath), resolves + write-gates each file, and applies them per file through the sharedapply_one— extracted from the old inline handler body and reused by the single-op path too. A batch may now legitimately span files.Also softens
ctx_read'smodedocs, which overclaimed "REQUIRED" though the param is optional and defaults toauto(issue item 2).Scope
Issue item 3 — modeling action-conditional requirements across
ctx_execute/ctx_searchwith JSONSchemaoneOf/if-then— is intentionally left as a follow-up rather than speculatively rewriting every tool schema in this PR.Tests
4 new pure grouping tests (cross-file order, top-level fallback, missing-path rejection, empty-ops). Full existing
ctx_patchsuite (86 tests incl. batch atomicity, syntax gate, BOM/CRLF, backups) passes.🤖 Generated with Claude Code