TeamDelete fails after agents approve shutdown - 'active members' not cleared

Resolved 💬 4 comments Opened Mar 24, 2026 by JinFuLee Closed Apr 21, 2026

Bug Description

After agents approve a shutdown_request, TeamDelete still fails with Cannot cleanup team with N active member(s). The agents have:

  1. Responded with shutdown_response approve: true
  2. System sent teammate_terminated message
  3. But agents continue sending idle_notification after termination
  4. TeamDelete still counts them as active members

Reproduction Steps

  1. Create a team with TeamCreate
  2. Spawn 2+ agents with Agent tool (team_name parameter)
  3. Send shutdown_request to each agent
  4. Wait for shutdown_response approve: true from each
  5. Wait for teammate_terminated system message
  6. Call TeamDelete
  7. Expected: Team deleted successfully
  8. Actual: Cannot cleanup team with N active member(s): agent1, agent2

Workaround

Force-removing team directories: rm -r ~/.claude/teams/{name} ~/.claude/tasks/{name}

Environment

  • Claude Code version: 2.1.81
  • OS: macOS Darwin 25.2.0 (Apple Silicon)
  • Model: Claude Opus 4.6 (1M context)

Impact

In long sessions with multiple team cycles (20+ agent spawns across 6+ teams), every TeamDelete fails. This forces manual directory cleanup and prevents clean team lifecycle management.

View original on GitHub ↗

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