Agent teams: stale pane ID prevents spawning new teams after TeamDelete

Resolved 💬 3 comments Opened Mar 4, 2026 by JKeeter Closed Mar 7, 2026

Description

After a team is deleted with TeamDelete, the internal pane tracking array retains the old iTerm2 pane ID. Spawning agents in a new team fails because the split logic tries to split from the dead pane.

This is distinct from #24385 (panes not closing on shutdown). Even when panes are properly closed and the team is fully deleted, the cached pane ID persists in the session and blocks all subsequent team usage.

Repro steps

  1. TeamCreate → spawn an agent via Agent with team_name — agent opens in iTerm2 split pane (works fine)
  2. shutdown_request → agent approves shutdown → TeamDelete succeeds
  3. Close the lingering pane (osascript tell aSession to close by unique ID)
  4. TeamCreate a second team → spawn a new agent → fails with:

``
Error: Session 'FE23EBFE-6FDD-42B7-A500-2C4DECDE802E' not found
``

The pane ID from step 1 is gone (pane closed, team deleted), but the split logic still references it.

Expected behavior

After TeamDelete, the pane tracking state should be fully reset. Spawning agents in a new team should work without restarting Claude Code.

Workaround

Restart Claude Code between team runs to clear the session-scoped pane cache.

Root cause (from #24385)

The internal pane tracking array (PW1 in the minified source) only supports push() and full reset — there's no removal of individual entries when a pane closes. The split logic may need to validate the target pane still exists before splitting, or fall back to the leader session.

TeamDelete should trigger a full reset of the pane tracking array, or the split logic should validate the target pane exists and fall back gracefully.

Environment

  • macOS 15 (Darwin 25.3.0)
  • iTerm2 native split pane mode
  • Claude Code with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

View original on GitHub ↗

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