Skip to content

Fix panic when sub-agent tool completes after primary agent's turn ends#69

Open
tcdent wants to merge 1 commit intomainfrom
claude/fix-agent-spawn-turn-bug-96dOC
Open

Fix panic when sub-agent tool completes after primary agent's turn ends#69
tcdent wants to merge 1 commit intomainfrom
claude/fix-agent-spawn-turn-bug-96dOC

Conversation

@tcdent
Copy link
Owner

@tcdent tcdent commented Feb 8, 2026

The ToolEvent::Completed handler was unconditionally draining injectable
notifications and calling finish_turn()/begin_turn() on the transcript,
even for sub-agent tool completions. When the primary agent had already
finished its turn, this created an orphaned active turn that nobody would
finish, causing a panic ("Cannot begin turn: previous turn not finished")
on the next user submit.

Guard the notification injection behind an is_primary check so only the
primary agent's tool completions manipulate the transcript turn lifecycle.

https://claude.ai/code/session_01RimYSQyprjibcxqX8XBmrD

The ToolEvent::Completed handler was unconditionally draining injectable
notifications and calling finish_turn()/begin_turn() on the transcript,
even for sub-agent tool completions. When the primary agent had already
finished its turn, this created an orphaned active turn that nobody would
finish, causing a panic ("Cannot begin turn: previous turn not finished")
on the next user submit.

Guard the notification injection behind an is_primary check so only the
primary agent's tool completions manipulate the transcript turn lifecycle.

https://claude.ai/code/session_01RimYSQyprjibcxqX8XBmrD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants