[Bug] Escape terminates background subagents instead of interrupting foreground turn only

Resolved 💬 2 comments Opened Jun 25, 2026 by fosterbrereton Closed Jun 29, 2026

Bug Description
Title: Escape terminates background subagents instead of only interrupting the foreground turn

Summary: Pressing Escape (single and/or double) in the REPL kills running background agents. Per the docs, Escape should only interrupt the current foreground generation; the documented way to stop background subagents is Ctrl+X Ctrl+K (press twice). Escape stopping them looks like an unintended side effect.

Expected:

  • Single Esc → interrupt the current foreground turn only.
  • Double Esc → clear the input draft / open rewind menu.
  • Background subagents (spawned via the Agent tool with run_in_background) keep running across an Esc.
  • Only Ctrl+X Ctrl+K (×2) should stop background subagents.

Actual: Hitting Esc a couple of times also terminated a running background subagent — UI showed Background agent "<name>" was stopped by the user. The agent had to be relaunched manually.

Repro:

  1. Spawn a long-lived background agent (Agent tool, run_in_background: true).
  2. Confirm it's running.
  3. Press Esc once or twice to interrupt the foreground / clear input.
  4. Observe the background agent gets stopped, not just the foreground turn.

Impact: Persistent background teammates (e.g. a scheduler/maintenance agent) die on a routine Esc, silently dropping their owned work until manually restarted. There's no way to interrupt the foreground without risking background agents short of avoiding Esc entirely.

Workaround in use: Using Ctrl+C to interrupt instead, or rebinding esc in ~/.claude/keybindings.json.

Environment: Claude Code 2.1.191, macOS (Darwin 24.6.0).

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.191
  • Feedback ID: 69b27794-9c8a-4db5-af47-ce73d3f4549e

View original on GitHub ↗

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