claude-code - 💡(How to fix) Fix [MODEL] Sub-agents (Haiku) over-edit structured config files despite explicit "surgical edits only" instructions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

Repro: not trivial to share publicly (proprietary codebase), but the pattern is: large XML project file + sub-agent prompt asking for surgical edits + sub-agent treats it as a full rewrite.

---
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues for similar behavior reports
  • This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Claude modified files I didn't ask it to modify

What You Asked Claude to Do

In a session involving a large legacy C++/C# modernization workspace (~100 csprojs, ~3000-line .vcxproj files), Opus model delegated specific surgical edits to Haiku sub-agents via the Agent tool. The prompts explicitly stated:

  • "Use ONLY the Edit tool with small surgical old_string/new_string pairs"
  • "Do NOT rewrite the file"
  • "Do NOT reformat XML or reorder elements"
  • "Net diff should be ≤300 lines; STOP and report if exceeded"

What Claude Actually Did

Despite these constraints, Haiku:

  1. Rewrote a 3159-line WellTech.vcxproj down to 2973 lines (186 lines net change, full reformat, attribute reordering).
  2. Rewrote 7 wrapper .csproj files entirely instead of dropping a single 3-line ItemGroup block.
  3. Re-introduced cycle-creating <ProjectReference Include="..\xxx.vcxproj"> ProjectRefs in csprojs whose depot version explicitly removed them (with surrounding comments stating "Wave A5 Phase 2 (2026-05-25): removed the ProjectReference... to break MSBuild cycle"). The committed comments would have been visible to anyone Reading the file but Haiku rewrote past them.

Compounding issue — unverified "pre-existing" framing: Haiku's reports framed regression errors as "pre-existing baseline issues" without comparing against a known-green build log. Example: 50 NU1108 cycle errors were declared "pre-existing Valve cycle" — but the prior session ended with 0 errors per the resume prompt + the day's earlier successful build log was right there on disk.

Expected Behavior

  1. When a prompt to Agent contains phrases like "surgical edit", "do not rewrite", or explicit line-count caps, the agent's Write tool calls on existing files (especially XML/structured config) could be soft-blocked or require explicit confirmation.
  2. Sub-agent "pre-existing" or "baseline" framings could require citing a specific build log path + line range to substantiate.
  3. After a sub-agent finishes, Opus's verification step could be more strongly suggested for structured-config edits (vcxproj, csproj, sln) — diff size sanity check before proceeding.

Files Affected

Repro: not trivial to share publicly (proprietary codebase), but the pattern is: large XML project file + sub-agent prompt asking for surgical edits + sub-agent treats it as a full rewrite.

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Haven't tried to reproduce

Steps to Reproduce

No response

Claude Model

Opus

Relevant Conversation

Impact

High - Significant unwanted changes

Claude Code Version

2.1.154

Platform

Anthropic API

Additional Context

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING