5986583641
rootDescendantCounts was incremented on every spawn but never decremented when tasks reached terminal states (completed, cancelled, error, interrupt, stale-pruned). This made maxDescendants=50 a session-lifetime quota instead of its intended semantics as a concurrent-active agent cap. Fix: add unregisterRootDescendant() in five terminal-state handlers: - tryCompleteTask(): task completes successfully - cancelTask(): running task cancelled (wasRunning guard prevents double-decrement for pending tasks already handled by rollbackPreStartDescendantReservation) - session.error handler: task errors - promptAsync catch (startTask): task interrupted on launch - promptAsync catch (resume): task interrupted on resume - onTaskPruned callback: stale task pruned (wasPending guard) Fixes: code-yeongyu/oh-my-openagent#2700