Skip to content

Esc-cancel during blocking read_agent (wait:true) also kills the running background agent #3980

Description

@antonech

Description

When a background agent is running and the assistant calls read_agent with wait: true, pressing Esc twice (cancel) to interrupt that blocking wait cancels not only the read but the underlying background agent itself. The agent is terminated and becomes unrecoverable.

Steps to reproduce

  1. Start a background agent via the Task tool (mode: background).
  2. The assistant calls read_agent with wait: true on that agent.
  3. Press Esc twice to cancel while it is waiting.
  4. The tool returns: The execution of this tool, or a previous tool was interrupted.
  5. A later read_agent (wait: false) returns Agent not found — the background agent was killed.

Expected behavior

Esc/cancel during a blocking read should cancel only the read (stop waiting). The background agent should keep running and remain readable later.

Actual behavior

The background agent is terminated along with the cancelled read, losing all in-flight progress.

Impact

Silent loss of in-flight background work. A cancel intended only for the foreground wait destroys the background task.

Environment

  • Copilot CLI version: v1.0.66
  • OS: Linux

Notes

Reproduced twice in one session (two explore background agents both became Agent not found after an Esc-cancelled blocking read_agent).

Workaround

Avoid wait: true on read_agent; rely on completion notifications plus non-blocking read_agent polls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:input-keyboardKeyboard shortcuts, keybindings, copy/paste, clipboard, mouse, and text input

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions