[BUG] Background agent handle becomes unreachable after context summarization, even though agent is still running

Open 💬 0 comments Opened Jul 15, 2026 by gdytelus

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

After spawning a background Agent (async subagent, e.g. run_in_background: true), the agentId/handle returned in the tool result can become unreachable to the assistant later in the same session — even though the agent is still confirmed running (visible as "running in background" in the session UI). Attempts to SendMessage to the agent (by name or by the previously-returned agentId) fail with "No agent named '...' is reachable," despite the background task list showing it as active.

This appears related to conversation context summarization/compaction: once the tool-result message containing the agentId is summarized out of context, the assistant loses the only reference needed to address that agent, with no fallback way to re-discover the ID for an agent it itself spawned earlier in the same session.

What Should Happen?

The assistant should always be able to enumerate and address background agents it spawned for the lifetime of the session (e.g. via a TaskList-equivalent that surfaces live agent IDs/names), independent of whether the original spawn tool-result has been summarized out of the visible context window.

Steps to Reproduce

  1. In a long-running session, call the Agent tool twice with run_in_background: true, noting the agentId returned in each tool result.
  2. Continue the conversation long enough (or trigger enough turns) that context summarization/compaction occurs.
  3. Attempt SendMessage to one of the spawned agents using its name or the previously-seen agentId.
  4. Observe: {"success":false,"message":"No agent named '...' is reachable. Check the spelling, or use the agent ID from a background agent's spawn result."} — even though the agent is still shown running in the background task UI.

Note: the bug is that there's no way for the assistant to re-fetch/list the agentId after the spawn result has scrolled out of context — not that the agent itself stopped running.

Additional Information

Observed on Windows 11 (win32), Git Bash (MINGW64), Claude Code CLI, model claude-sonnet-5, in a project using background subagents (general-purpose and specialized types) for multi-node log/health checks.

View original on GitHub ↗