Repository navigation
Count a non-exec launcher chain as one agent in the Claude status guard - #651
Conversation
The adapter's topology walk counted every process whose argv[0] basename is an agent, so a compiled launcher that runs the real binary without exec read as a spawner and silenced the pane's own hooks. A consecutive run of one agent name now counts once; a spawned worker always has its tool call's shell between it and the spawner. Fixes umputun#649
umputun
left a comment
There was a problem hiding this comment.
one change before merge. The adjacency rule also admits a Claude worker spawned as a direct child of the pane's claude, so that worker's hooks can update the pane owner's status. Claude Code runs a string hook through /bin/sh -c, and macOS sh exec-replaces a single simple command, so a hook whose whole command is claude -p ... (a matcher-scoped PostToolUse, Notification or PreCompact hook) leaves claude -> claude -> adapter with no shell in between. On master the adapter stays silent there, on this branch it forwards completed --auto-reset, and a blocked glyph can be cleared until the owner's next event.
I'm fine accepting that as a limitation of the launcher-chain heuristic. A start-time check wouldn't settle ownership either, a fresh pane agent can spawn a worker inside any threshold. But the comment and the guide shouldn't promise that every worker stays silent:
agterm/Resources/agent-status/agterm-claude-status.sh:9- "a spawned worker always has the shell its tool call started between it and the spawner" describes the usual tool-call chain, and a hook-spawned worker breaks it. Fix: make the retained shell the condition and name adjacent same-name workers as accepted.site/docs.html:3275- "When Claude Code runs as a worker under another agent, its hooks stay silent" no longer holds for a direct child. Fix: qualify it to workers separated from their parent agent by a surviving shell process.
A hook whose whole command is `claude -p ...` runs through `sh -c`, which execs it, so the worker is a direct child of the pane's claude and the adjacency rule reads the pair as one agent. The adapter comment and the guide now name a surviving process between worker and spawner as the condition, and the direct-child case as an accepted limitation.
|
Thanks, confirmed that |
Fixes #649.
The Claude status adapter's topology walk counted every ancestor whose argv[0] basename is an agent. A compiled launcher that spawns the real binary without
execleaves severalclaudepids in a row, so the pane's own agent read as a worker and its hooks were silenced. A consecutive run of one agent name now counts once. A spawned worker always has its tool call's shell between it and the spawner, so worker detection is unchanged.Tradeoff: an agent that spawns the same agent as a direct child, with no process in between, now reads as one agent. One real path to that shape is a hook whose whole command is
claude -p ..., which/bin/sh -cexecs directly under the pane'sclaude. That worker now reports, and can clear ablockedglyph until the owner's next event. The adapter comment andsite/docs.htmlstate the surviving-process condition and name this as an accepted limitation.Tests:
spawnedWorkerStaysSilentandruntimeHostedAgentIsCountedThroughArgv1now interpose the shell a real tool call has, since a directly adjacent same-name pair is now read as a launcher chain.nonExecLauncherChainCountsAsOneAgentandworkerUnderLauncherChainStaysSilent.Verification: the machine I worked on has no Xcode or SwiftLint, so
swift test,make test-app,make lint, and the build have not run locally; I'm relying on CI. I ran the test file's chain shapes through its spawner script in bash, plus a compiledposix_spawnlauncher (the repro in the issue comment) and a real three-binary launcher chain. The current script is silent in each launcher case and the patched one reports, while worker cases stay silent.Existing installs pick this up by re-running Help > Install Agent Status Hooks.