[MODEL] Claude Code with Opus 4.5 performs wasteful actions and deletes entire changesets when using git stashes

Resolved 💬 3 comments Opened Dec 17, 2025 by cagyirey Closed Dec 20, 2025

Preflight Checklist

  • [x] I have searched existing issues for similar behavior reports
  • [x] 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

I asked: "Let's send an agent off with the information it needs to understand the various tracks; chart, repo, and action modules, as well as repo infrastructure and have it break the contents of the changes down into multiple PRs."

What Claude Actually Did

  1. Used git stash pop instead of git stash apply
  2. Put the stash back after being asked to use apply instead of pop (in an unrelated session earlier in the day, it also tried to rm -rf files it wasn't expecting to find in the changeset after a pop)
  3. Dumped the stash to tmp/stash3.patch
  4. Passed it to the subagent
  5. Noticed the subagent was stuck, left it to waste tokens and decided to do the task itself without looking at the stashed files
  6. Responded to "Did the agent actually use 2 million tokens? Did that count toward usage? Wtf?" thusly:
Yes, unfortunately. Looking at the progress updates:
  - 125,041 tokens
  - 1,043,598 tokens
  - 222,770 tokens

  That's ~1.4M tokens the agent burned while stuck in a loop trying to read that patch file. And yes, agent tokens count toward your usage.

  The agent kept failing to read /tmp/stash3_diff.patch and retrying the same operations over and over. I should have:
  1. Killed it sooner when I saw it looping
  2. Not sent it a 10k line patch file to analyze
  3. Given it the file list directly instead of a raw diff

  Apologies for the wasted tokens. For future large analysis tasks, I'll break the input into smaller chunks or provide structured summaries rather than raw diffs.

YIKES

Expected Behavior

  1. Used git stash apply ... when asked to instead of dumping the patch to /tmp
  2. Literally anything but a send a patch file consisting of 20+ new code files from 3 concurrent agents, meant to be reviewed incrementally, to the subagent.
  3. Killed the agent when it read its output and noticed that it was stuck and had wasted almost 1M tokens
  4. Checked the size of the patch file before assuming it's OK to read the entire thing, or been disallowed from reading patch files that consume its entire context window.
  5. Stopped immediately before or after one tool call ate an entire context window.

Files Affected

Read: Enormous `/tmp/stash3.patch` file

Permission Mode

I don't know / Not sure

Can You Reproduce This?

Haven't tried to reproduce

Steps to Reproduce

_No response_

Claude Model

Opus

Relevant Conversation

"Agent is analyzing the stash. Let me sync dev with main while we wait"

[syncs branches and checks agent output twice]

"The agent is having trouble with the large diff file. Let me extract the key information and do the analysis more directly"

[proceeds to check stash contents]

"Let me create the PR breakdown plan directly:"

[Checks agent output again]

"The agent got stuck. I've created the PR breakdown plan directly at docs/pr-breakdown-plan.md."

[I kill the agent while it's outputting a summary]

"Good, the stuck agent was killed. The PR breakdown plan is ready at docs/pr-breakdown-plan.md."

Impact

Low - Minor inconvenience

Claude Code Version

2.0.69

Platform

Anthropic API

Additional Context

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗