improve: show edit mismatch candidate lines#97269
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 8:29 AM ET / 12:29 UTC. Summary PR surface: Source +268, Tests +164. Total +432 across 2 files. Reproducibility: yes. Current main source only appends the generic exact-match error plus capped current file contents, while PR proof and tests exercise production createEditTool mismatch output with candidate diagnostics. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land one bounded edit-tool diagnostic implementation with the maintainer-approved wording, then close or rebase the sibling PRs against that canonical choice. Do we have a high-confidence way to reproduce the issue? Yes. Current main source only appends the generic exact-match error plus capped current file contents, while PR proof and tests exercise production createEditTool mismatch output with candidate diagnostics. Is this the best way to solve the issue? Yes for the code path, with one maintainer caveat. The edit-tool mismatch wrapper is the right owner boundary and the current implementation is bounded, but maintainers still need to pick the canonical output contract among sibling PRs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3c530c79a05b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +268, Tests +164. Total +432 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (13 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Updated this branch to address the previous lint/review blockers and refreshed the Evidence section with real edit-tool mismatch output plus focused validation. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Have a nice day, please help merge! |
|
@clawsweeper re-review Addressed the waiting-on-author boundedness finding in 3fd09be and updated the PR body Evidence section with focused edit-tool regression proof. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Current head
Current-head checks are green: |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Current head |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
Thanks @qingminglong. The canonical fix for #97032 landed through #97038 as 4204a948457cafc601c1f27a1965fcfb011c2131. We selected #97038 because it keeps the diagnostic in the shared edit-diff owner path, bounds both scan cost and output, and covers typo, indentation, escaping, cap, and surrogate-safe truncation behavior with focused tests. This PR targets the same behavior, so I’m closing it as superseded. Your parallel implementation helped validate the need and solution space. |
Closes #97032
What Problem This Solves
Resolves a problem where edit tool
oldTextmismatch failures only showed the generic exact-match error plus current file contents, leaving users to guess whether indentation, escaping, or nearby text drift caused the miss.Why This Change Was Made
The edit mismatch path now appends bounded nearest-candidate diagnostics with line numbers, escaped line diffs, and indentation hints when the failing edit can be identified. Matching behavior is unchanged: the tool still requires the same exact/fuzzy edit semantics, and validation-phase no-op mismatch errors avoid candidate guesses when the indexed edit source is ambiguous.
User Impact
Users and agents get actionable feedback after a failed edit call: the error can point at nearby candidate lines and show the visible difference, while still preserving the existing current-file-content hint.
Evidence
node --import tsxagainstcreateEditTool()on a temp file and intentionally submitted anoldTextindentation mismatch. Result: the thrown edit-tool error includedNearest candidate lines:,Candidate 1 (line 2):,indentation: expected 6 spaces, candidate 2 spaces, and escaped diff lines (- " return value;"/+ " return value;") after the redactedCurrent file contents:block.node scripts/run-vitest.mjs src/agents/sessions/tools/edit.test.ts- passed, 30 tests.node scripts/run-vitest.mjs src/agents/agent-tools.create-openclaw-coding-tools.test.ts- passed, 66 tests.node scripts/run-vitest.mjs src/cron/isolated-agent/run-fallback-policy.test.ts src/docs/clawhub-plugin-docs.test.ts src/config/talk-defaults.test.ts src/docs/environment-docs.test.ts src/agents/minimax-docs.test.ts- passed, covering the five CI red-log test families from run 28729651276 on the current PR head.git diff --check- passed.python .agents\skills\autoreview\scripts\autoreview --mode local- clean, no accepted/actionable findings reported.$env:OPENCLAW_OXLINT_SKIP_PREPARE='1'; node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/sessions/tools/edit.ts src/agents/sessions/tools/edit.test.tswas blocked before linting by missing optional Windows platform package@oxlint-tsgolint/win32-x64/tsgolint.exe;pnpm install --frozen-lockfilewas retried once and timed out after 120s, and the commit hook also showed missing optional@oxfmt/binding-win32-x64-msvc.Follow-up after ClawSweeper waiting-on-author review (commit 3fd09be):
Follow-up after July 5 review blocker (commit 4ced22d):
Follow-up after CI red-log docs failures (commit b5124f7):
Follow-up after removing unrelated QA timeout hunk (commit 475a968):
Follow-up after current-head bounded collector repair (commit b5ed9e2, head b5ed9e2):