[BUG] Stale shutdown_request in team message queue terminates newly spawned teammate

Resolved 💬 1 comment Opened Apr 9, 2026 by LeeSangMin1029 Closed Apr 9, 2026

Description

When a shutdown_request is sent to a teammate agent via SendMessage, and the teammate is then re-spawned with the same name in the same team, the new agent immediately receives the old shutdown_request from the message queue and terminates itself.

Steps to Reproduce

  1. Create a team: TeamCreate: name=my-team
  2. Spawn a teammate: Agent: name=committer, team_name=my-team
  3. Send shutdown: SendMessage: to=committer, message={type: "shutdown_request"}
  4. Teammate shuts down
  5. Spawn a new teammate with the same name: Agent: name=committer, team_name=my-team
  6. Expected: New agent is ready and waiting for messages
  7. Actual: New agent immediately receives the old shutdown_request and terminates

Observed Behavior

// Step 5: spawn new committer
Spawned successfully. agent_id: committer@my-team

// Immediately after:
{"type":"idle_notification","from":"committer","idleReason":"available"}
{"type":"teammate_terminated","message":"committer has shut down."}
{"type":"shutdown_approved","requestId":"shutdown-1775755623068@committer"}

The requestId matches the previous shutdown request, confirming the new agent consumed a stale message.

Expected Behavior

  • Shutdown requests should be scoped to a specific agent instance, not just the agent name
  • When an agent is terminated and a new one spawned with the same name, the message queue should be cleared of stale messages from the previous instance
  • Alternatively, shutdown_response messages should include the agent_id and be validated against the current instance

Environment

  • Claude Code version: 2.1.97
  • OS: Windows 11
  • Terminal: bash

Workaround

Currently the only workaround is to spawn the new agent with a different name (e.g., committer-2) or create an entirely new team, which is impractical for long-running workflows.

Impact

This makes it impossible to reliably restart a teammate agent within the same team. Any workflow that needs to stop and restart a specific agent role (e.g., a commit agent that is spawned per-session) is affected.

Related Issues

  • #31788 — TeamDelete blocked by hung agent
  • #34614 — Teammates silently exit after spawn
  • #25254 — Messages not delivered, agent deadlock
  • #24385 — Stale pane tracking after shutdown

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗