claude-code - 💡(How to fix) Fix [BUG] Agent restarts work on its own, even after interruption [3 comments, 2 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#47874Fetched 2026-04-15 06:39:51
View on GitHub
Comments
3
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×4commented ×3

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code restarts working on its own if an old process finishes work, even after manually interrupting the work. This happens even if you stopped and restarted the process in the meantime.

Here's a case where I had a process running in the background in the previous session, interrupted the model, closed the app, restarted it and just waited without any input at all:

<img width="1184" height="414" alt="Image" src="https://github.com/user-attachments/assets/00b08a17-3ec6-469e-b706-e251e6956d0d" />

What Should Happen?

App shouldn't start any work on its own, ever. Especially when idle, since that results in extra API costs without user input.

Error Messages/Logs

Steps to Reproduce

  1. Run a prompt that will result in a long-running background process
  2. Exit cloud code
  3. Start it again and wait
  4. When the process finishes, claude will start running more prompts on its own

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The issue can be mitigated by ensuring that Claude Code properly cleans up and terminates any background processes when interrupted or stopped.

Guidance

  • Investigate the process management in Claude Code to ensure that it correctly handles interrupted or stopped processes, preventing them from restarting automatically.
  • Review the code for any potential issues with process termination, such as unclosed threads or unhandled exceptions, which could cause the process to remain active.
  • Consider adding logging or debugging statements to track the state of background processes and identify why they are restarting unexpectedly.
  • Examine the interaction between Claude Code and the Anthropic API to determine if there are any API-specific settings or configurations that could be contributing to the issue.

Example

No specific code example can be provided without more information about the internal workings of Claude Code. However, ensuring proper process termination might involve using try-finally blocks or similar constructs to guarantee cleanup.

Notes

The exact cause of the issue is unclear without more detailed logs or code insights. The problem might be related to how Claude Code manages its background processes or interacts with the Anthropic API.

Recommendation

Apply a workaround by closely monitoring and manually terminating any unexpected background processes until a more permanent fix can be implemented. This approach is chosen due to the lack of information about the root cause and the potential for the issue to be related to a complex interaction between Claude Code and the Anthropic API.

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