fix: prevent watchdog from killing teammates prematurely#1369
Merged
louisgv merged 1 commit intoOpenRouterTeam:mainfrom Feb 17, 2026
Merged
fix: prevent watchdog from killing teammates prematurely#1369louisgv merged 1 commit intoOpenRouterTeam:mainfrom
louisgv merged 1 commit intoOpenRouterTeam:mainfrom
Conversation
The result event detection in refactor.sh, discovery.sh, and security.sh was killing the entire process tree 30s after the team lead's session ended. In team-based workflows, the team lead's "result" event fires after spawning teammates — while the actual work is still running as child processes. Instead of immediately killing on result detection, monitor the claude process's child processes via pgrep. While teammates are running, reset the idle counter to prevent false timeouts. Only shut down once all teammate processes have completed (or the hard timeout fires). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
louisgv
approved these changes
Feb 17, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Findings
No security issues found. The changes introduce process monitoring logic to prevent premature termination of teammate processes.
Analysis:
- Command injection: All variables are script-controlled (LEAD_PID from PID file). pgrep validates numeric PIDs internally.
- File operations: PID file paths are script-controlled, not user-supplied.
- Error handling: Proper fallback with
2>/dev/null || truepattern. - Logic: Monitors child processes via
pgrep -Pafter team lead completes, resets idle timeout while children are active.
Tests
- bash -n: PASS (all 3 files)
- bun test: N/A (shell scripts only)
- curl|bash: N/A (internal scripts, not curl|bash targets)
- macOS compat: OK (uses standard pgrep/cat/kill commands)
-- security/pr-reviewer-1369
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
refactor.sh,discovery.sh, andsecurity.shdetects the team lead's"type":"result"stream-json event and kills the entire process tree after 30sresultfires immediately after spawning teammates — while teammates have barely started workingresult, monitor the claude process's child processes viapgrep -P. While teammates are running, reset the idle counter. Only shut down once all child processes have completed (or the hard timeout fires as a backstop)Evidence from run #22082135329:
01:06:1001:06:25(15s later)01:06:59(only 49s of teammate runtime)Test plan
bash -npasses on all three modified files🤖 Generated with Claude Code