anthropics / anthropics/claude-code

Ctrl+C intended to clear the prompt input killed 6 running background agents (no confirmation)

Open
#95,081 0 comments 0 reactions 0 assignees View on GitHub
area:agents area:tui bug has repro platform:macos
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

## Summary

With several background agents running (Agent tool, `run_in_background` / async subagents), pressing **Ctrl+C once** to clear text I had typed in the prompt did not clear the input — it **stopped all six background agents** immediately, with no confirmation. The session then reported: "6 background agents were stopped by the user".

Ctrl+C is normally the clear-input key when the prompt has text, so this is a destructive key-binding collision: the same keystroke is "clear my typo" in one state and "kill every agent I have working" in another, and the difference is not visible to the user at the moment they press it.

## Impact

Six long-running agents (a P0 incident fix: database migrations, GraphQL resolvers, web UI, CI, observability, connection pooling) were killed mid-work after roughly 40 minutes of parallel effort. Their worktrees survived, but each had to be relaunched with salvage instructions, and unpushed in-flight work had to be recovered by hand. The interruption happened during an active production incident.

## Environment

- Claude Code CLI 2.1.257 (Claude Code) on macOS (Darwin 25.6.0), zsh, interactive terminal
- Background agents launched via the Agent tool with worktree isolation; one foreground turn in progress (the assistant had just answered a question)
- Auto mode / permission classifier active

## Steps to reproduce

1. Launch 3+ background agents (e.g. Agent tool, background) so they are running.
2. While they run, type some text into the prompt input (do not submit).
3. Press Ctrl+C once, intending to clear the typed text.

## Expected

Ctrl+C clears the input buffer (its normal behaviour when the prompt has text). Stopping background agents should require an explicit, discoverable action — a dedicated command, a double Ctrl+C with a visible "press again to stop N agents" prompt, or a confirmation — and should never share a single keystroke with clear-input.

## Actual

All running background agents were stopped on the first Ctrl+C. No confirmation, no undo.

## Suggested fixes

- Never bind agent termination to single Ctrl+C while the input buffer is non-empty; clear input first.
- When background agents are running, require a second Ctrl+C within a short window (with an on-screen warning naming the agent count) or a `/stop-agents` style command.
- Offer "resume the stopped agents" after an accidental stop, since their transcripts/worktrees still exist.

Filed on behalf of the account owner at their request.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Claude Code CLI interactive prompt's Ctrl+C handling and the Agent tool/run_in_background async-subagent stop path; the payload names no source files or tests. Reproduce with several agents and non-empty input, then trace which handler receives the key; done means typed input is cleared without stopping agents and agent termination uses an explicit, visible action or confirmation, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, zsh
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.