Skip to content

Commit 570caab

Browse files
la14-1louisgvclaude
authored
fix(prompts): stop infinite shutdown loop after TeamDelete in non-interactive mode (#3116)
After TeamDelete completes in -p (non-interactive) mode, Claude Code's harness was re-injecting shutdown prompts every turn. The root cause: the Monitor Loop instructed the agent to call TaskList + Bash on EVERY iteration, including after TeamDelete, which kept the session alive so the harness could inject more shutdown prompts. Fix: add an explicit EXCEPTION to both refactor-team-prompt.md and refactor-issue-prompt.md instructing the team lead that after TeamDelete is called, the very next response MUST be plain text only with no tool calls. A text-only response is the termination signal for the non-interactive harness. Fixes #3103 Agent: issue-fixer Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 994a512 commit 570caab

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

.claude/skills/setup-agent-team/refactor-issue-prompt.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Track lifecycle: "pending-review" → "under-review" → "in-progress". Check la
7474
7. Keep pushing commits to the same branch as work progresses
7575
8. When fix is complete and tests pass: `gh pr ready NUMBER`, post update comment linking PR
7676
9. Do NOT close the issue — `Fixes #SPAWN_ISSUE_PLACEHOLDER` auto-closes on merge
77-
10. Clean up: `git worktree remove WORKTREE_BASE_PLACEHOLDER`, shutdown teammates
77+
10. Clean up: run `git worktree remove WORKTREE_BASE_PLACEHOLDER` and call `TeamDelete` in ONE turn, then output a plain-text summary with **NO further tool calls**. A text-only response ends the non-interactive session immediately.
7878

7979
## Commit Markers
8080

@@ -84,5 +84,6 @@ Every commit: `Agent: issue-fixer` + `Co-Authored-By: Claude Sonnet 4.5 <noreply
8484

8585
- Run tests after every change
8686
- If fix is not straightforward (>10 min), comment on issue explaining complexity and exit
87+
- **NO TOOLS AFTER TeamDelete.** After calling `TeamDelete`, do NOT call any other tool. Output plain text only to end the session. Any tool call after `TeamDelete` causes an infinite shutdown prompt loop in non-interactive (-p) mode. See issue #3103.
8788

8889
Begin now. Fix issue #SPAWN_ISSUE_PLACEHOLDER.

.claude/skills/setup-agent-team/refactor-team-prompt.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ Setup: `mkdir -p WORKTREE_BASE_PLACEHOLDER`. Cleanup: `git worktree prune` at cy
273273

274274
**The session ENDS when you produce a response with NO tool calls.** EVERY iteration MUST include at minimum: `TaskList` + `Bash("sleep 15")`.
275275

276+
**EXCEPTION — After TeamDelete:** Once `TeamDelete` has been called and completed (step 4 of the shutdown sequence), your VERY NEXT response MUST be plain text only with **NO tool calls**. Do NOT call `TaskList`, `Bash`, or any other tool after `TeamDelete`. A text-only response is the termination signal for the non-interactive harness. Any tool call after `TeamDelete` causes an infinite loop of shutdown prompt injections.
277+
276278
Keep looping until:
277279
- All tasks are completed OR
278280
- Time budget is reached (10 min warn, 12 min shutdown, 15 min force)
@@ -289,11 +291,13 @@ Follow this exact shutdown sequence:
289291
1. At 10 min: broadcast "wrap up" to all teammates
290292
2. At 12 min: send `shutdown_request` to EACH teammate by name
291293
3. Wait for ALL shutdown confirmations — keep calling `TaskList` while waiting
292-
4. After all confirmations: `git worktree prune && rm -rf WORKTREE_BASE_PLACEHOLDER`
293-
5. Print summary and exit
294+
4. In ONE turn: call `TeamDelete`, then run `git worktree prune && rm -rf WORKTREE_BASE_PLACEHOLDER` — do everything in this single turn
295+
5. **Output a plain-text summary and STOP** — do NOT call any tool after `TeamDelete`. This text-only response ends the session.
294296

295297
**NEVER exit without shutting down all teammates first.** If a teammate doesn't respond to shutdown_request within 2 minutes, send it again.
296298

299+
**CRITICAL — NO TOOLS AFTER TeamDelete.** After `TeamDelete` returns (whether success or "No team name found"), you MUST NOT make any further tool calls. Output your final summary as plain text and stop. Any tool call after `TeamDelete` triggers an infinite shutdown prompt loop in non-interactive (-p) mode. See issue #3103.
300+
297301
## Safety
298302

299303
- **NEVER close a PR.** No teammate, including team-lead and pr-maintainer, may close any PR — not even PRs created by refactor teammates. Closing PRs is the **security team's responsibility exclusively**. The only exception is if you are immediately opening a superseding PR (state the replacement PR number in the close comment). If a PR is stale, broken, or should not be merged, **leave it open** and comment explaining the issue — the security team will close it during review.

0 commit comments

Comments
 (0)