Teaming agent spawn fails with 'Could not determine pane count' under iTerm2 tmux -CC integration

Resolved 💬 4 comments Opened Feb 8, 2026 by swizzlr Closed Mar 9, 2026

Description

When using Claude Code's teaming feature under iTerm2's native tmux integration (tmux -CC control mode), spawning teammates succeeds on the first team lifecycle but fails on subsequent ones with the error:

Could not determine pane count for current window

Environment

  • OS: macOS Darwin 25.2.0
  • Terminal: iTerm2 with native tmux integration (tmux -CC control mode)
  • Relevant env vars: ITERM_SESSION_ID, LC_TERMINAL=iTerm2 set
  • Claude Code: latest

Steps to Reproduce

  1. Open iTerm2 with native tmux integration active (tmux -CC)
  2. Start Claude Code
  3. Create a team with TeamCreate, spawn 3 teammates — works fine
  4. Teammates complete their work; shut them down and delete the team
  5. Create a second team with TeamCreate
  6. Attempt to spawn teammates — fails with "Could not determine pane count for current window"

Expected Behavior

Agent spawning should work across multiple team lifecycles within the same session.

Actual Behavior

The first batch of teammate spawns succeeds. The second batch fails with the pane count error. Two leftover tmux sessions (session 0 and session 1) were found after the failure, each containing a single fish shell pane at 80x25. These appear to be remnants from the first successful team spawn that were not properly cleaned up.

Root Cause Hypothesis

Claude Code queries tmux for pane counts to manage teammate panes. iTerm2's -CC mode virtualizes tmux panes into native iTerm2 tabs/splits, intercepting the tmux control protocol. After the first team's panes are cleaned up, the tmux state as seen through the -CC control channel may become inconsistent — stale geometry, a detached control client, or pane IDs that iTerm2 has already cleaned up but tmux still reports.

Workaround

Exit iTerm2's tmux integration and run Claude Code in a regular terminal session (or regular tmux without -CC).

View original on GitHub ↗

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