Skip monitor auto-start inside agent/teammate Claude Code processes - #5
Closed
sophieow wants to merge 1 commit into
Closed
Skip monitor auto-start inside agent/teammate Claude Code processes#5sophieow wants to merge 1 commit into
sophieow wants to merge 1 commit into
Conversation
The plugin's monitors.json when:"always" auto-starts client.py in every Claude Code process — including agent-team teammates / subagents spawned as child claude processes. Each worker then joins the bus with a cwd-derived name (roster collision chains with no human session behind them), and a broadcast reaches mid-task workers, whose reaction policy treats incoming text as an instruction. _in_agent_context() walks up to 15 ancestors and returns True when one is a claude binary (argv[0] "claude"* or the versioned install path .../claude/versions/<v>) carrying --agent-id / --parent-session-id as exact argv tokens; main() skips only the auto-start path (no --name), so an explicit --name still connects an agent deliberately. Fail-open on any error. 9 unit tests added; full suite 208 passed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
monitors.jsonwhen:"always"auto-startsclient.pyin every Claude Code process — including agent-team teammates / subagents spawned as child claude processes (claude --agent-id worker@team --parent-session-id <sid> …, argv[0] sometimes the versioned install path). With a 30-worker fleet we observed:myproject,myproject-2,myproject-2-2, …) with no human session behind them;broadcastreaching mid-task workers — the reaction policy treats incoming text as an instruction, a real derail hazard (mirrors the concern behind the skill's own SUBAGENT-STOP header).Fix
_in_agent_context(): walk up to 15 ancestors; return True when an ancestor is a claude binary (argv[0]claude*or the versioned install path…/claude/versions/<v>) carrying--agent-id/--parent-session-idas exact argv tokens — a shell ancestor merely quoting that text must not match.main()skips only the auto-start path (no--name); an explicit--namestill connects an agent deliberately. Fail-open on any error (psutil missing, AccessDenied mid-walk) so the normal connect path is never blocked.Testing
tests/test_agent_guard.py; full suite 208 passed.claudeand are not matched; abash -cancestor quoting the flag text is not matched.🤖 Generated with Claude Code