Skip to content

edit tool: show candidate lines with diff on oldText match failure #97032

Description

@aocogoal-gethub

Summary

edit tool reports 'not found' without showing what went wrong

Problem to solve

edit tool 的 oldText 匹配失败时只返回 "Could not find the exact text",不给任何诊断信息。用户不知道是转义写错了、缩进不对还是空白不匹配,只能盲猜。

Proposed solution

匹配失败时输出最多 3 个最近似候选行,包含行号、并排对比和差异标记:

  • 转义差异标注(\b vs \b)
  • 缩进差异标注(6空格 vs 12空格)
  • 仅增强错误输出,不改匹配算法,零副作用

Alternatives considered

无。当前行为是纯错误码,没有任何替代输出。

Impact

消除 edit tool 使用时的反复试错成本。2026-06-26 同一会话内出现 4 次此问题,每次失败原因不同但反馈相同。

Evidence/examples

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestimpact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions