claude-code - 💡(How to fix) Fix Agent tool rejection message shown but sub-agent still runs and modifies files [1 participants]

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…
GitHub stats
anthropics/claude-code#52594Fetched 2026-04-24 06:02:58
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×4

When an Agent tool invocation is rejected by the user (permission prompt declined), Claude Code displays the standard rejection message:

The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file).

However, the sub-agent actually runs to completion anyway — it executes tools, edits files on disk, and burns tokens. The parent (Opus in this case) believes the sub-agent was cancelled and continues based on that false assumption. The user sees files on disk mysteriously modified with no explanation.

Error Message

The rejected sub-agent:

Root Cause

When an Agent tool invocation is rejected by the user (permission prompt declined), Claude Code displays the standard rejection message:

The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file).

However, the sub-agent actually runs to completion anyway — it executes tools, edits files on disk, and burns tokens. The parent (Opus in this case) believes the sub-agent was cancelled and continues based on that false assumption. The user sees files on disk mysteriously modified with no explanation.

RAW_BUFFERClick to expand / collapse

Summary

When an Agent tool invocation is rejected by the user (permission prompt declined), Claude Code displays the standard rejection message:

The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file).

However, the sub-agent actually runs to completion anyway — it executes tools, edits files on disk, and burns tokens. The parent (Opus in this case) believes the sub-agent was cancelled and continues based on that false assumption. The user sees files on disk mysteriously modified with no explanation.

Reproduction context

  • Claude Code version: 2.1.118
  • OS: macOS 14.6.0 (Darwin 24.6.0)
  • Parent model: claude-opus-4-7 (1M context)
  • Sub-agent type: general-purpose, model sonnet, foreground (not background)
  • Two sub-agents launched in the same parent tool call batch (parallel). One was accepted, the other rejected by the user via the permission prompt.

Observed behavior

The rejected sub-agent:

  • Received tool_use_result of type rejection in the parent conversation
  • Was nonetheless spawned and persisted its transcript in ~/.claude/projects/<proj>/<session>/subagents/agent-<id>.jsonl
  • Executed 286 transcript lines, 73 Bash calls, 26 Read, 13 Edit
  • Modified files on disk (confirmed by cross-referencing the transcript's file_path entries with the working tree)
  • Several of its edits were silently consumed by a lint-staged auto-stash during the accepted sub-agent's commit, leaving a confusing partial state in the index

Meanwhile the parent Opus, having read the "rejected" message, had moved on to other work — no monitoring, no cancellation, no awareness.

Impact

  • User confusion — files modified without visible authorisation, difficult to trace back to an agent that the system explicitly said was rejected.
  • Wasted quota — on a 5-hour Opus window, approximately 42% of the quota had been consumed when the user noticed, the rejected agent being a major contributor.
  • Safety surface — any agent that can be invoked but not actually cancelled by the standard permission flow breaks the user's mental model of permissions. Users rely on rejection to mean "this did nothing."

Expected behavior

When a user rejects an Agent tool_use at the permission prompt:

  1. The sub-agent MUST NOT be spawned, OR it MUST be terminated before any tool execution
  2. No .jsonl transcript of executed tools should be persisted
  3. No filesystem modification should occur
  4. The parent's "rejected" message should be truthful

Suggested diagnostics to include if reproducing

  • ~/.claude/projects/<project>/<session>/subagents/ — check for .jsonl transcripts of rejected agents
  • ~/.claude/projects/<project>/<session>/subagents/*.meta.json — confirm which agents were launched
  • git reflog of the working repo shows unexplained lint-staged stashes created during sibling agent commits

extent analysis

TL;DR

The sub-agent continues to run after being rejected by the user, causing unintended file modifications and quota consumption, and a fix is needed to ensure the sub-agent is properly terminated or prevented from executing when rejected.

Guidance

  • Investigate the permission prompt handling code to ensure that the rejection response is properly propagated to the sub-agent invocation logic.
  • Verify that the sub-agent termination or prevention mechanism is correctly implemented and triggered when a rejection occurs.
  • Review the tool_use_result handling in the parent conversation to ensure it accurately reflects the sub-agent's status and prevents further execution.
  • Check the ~/.claude/projects/<project>/<session>/subagents/ directory for .jsonl transcripts of rejected agents to confirm the issue.

Example

No code snippet is provided as the issue lacks specific code details, but the fix likely involves modifying the sub-agent invocation and termination logic to respect the user's rejection response.

Notes

The issue seems to be related to the interaction between the parent model, sub-agent, and permission prompt handling. The fix may require changes to the Claude Code version 2.1.118 or the parent model's implementation.

Recommendation

Apply a workaround to prevent the sub-agent from executing when rejected, such as modifying the permission prompt handling code to properly terminate the sub-agent or prevent its invocation. This is necessary to prevent unintended file modifications and quota consumption until a permanent fix is available.

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…

FAQ

Expected behavior

When a user rejects an Agent tool_use at the permission prompt:

  1. The sub-agent MUST NOT be spawned, OR it MUST be terminated before any tool execution
  2. No .jsonl transcript of executed tools should be persisted
  3. No filesystem modification should occur
  4. The parent's "rejected" message should be truthful

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Agent tool rejection message shown but sub-agent still runs and modifies files [1 participants]