TeamDelete: cannot cleanup team with in-process agents after shutdown acknowledged

Resolved 💬 3 comments Opened May 9, 2026 by Maxymusss Closed May 13, 2026

Summary

TeamDelete refuses to clean up a team when it has in-process (backendType: "in-process") agents in the members[] array, even after all agents have acknowledged shutdown_request messages.

Steps to Reproduce

  1. Create a team with TeamCreate
  2. Spawn multiple agents (all backendType: "in-process")
  3. Complete work
  4. Send {"type": "shutdown_request"} to all agents
  5. All agents respond with {"type": "shutdown_response", "approve": true}
  6. Call TeamDelete

Expected

Team cleaned up — all agents have acknowledged shutdown.

Actual

Cannot cleanup team with N active member(s): agent-1, agent-2, ...
Use requestShutdown to gracefully terminate teammates first.

Root Cause

In-process agents share the host process and cannot independently exit. They can acknowledge shutdown via SendMessage response, but the members[] array in ~/.claude/teams/<name>/config.json is never updated to reflect their terminated state. TeamDelete treats any agent in members[] as "active" regardless of shutdown state.

The teammate_terminated system notification fires for some agents but not consistently — only 1 of 9 agents produced it in our test.

Workaround

Manually delete the team directories:

rm -rf ~/.claude/teams/<name>/
rm -rf ~/.claude/tasks/<name>/

Proposed Fix

Option A: SendMessage processing of shutdown_response with approve: true removes the agent from members[] in the team config.

Option B: TeamDelete checks a terminated flag on members, or treats shutdown_response-acknowledged agents as safe to clean up.

Option C: TeamDelete offers a --force flag that ignores active member count when the caller has lead-agent authority.

View original on GitHub ↗

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