Skip to content

Count a non-exec launcher chain as one agent in the Claude status guard - #651

Merged
umputun merged 2 commits into
umputun:masterfrom
TrevorBurnham:fix-649-wrapper-guard
Sep 26, 2026
Merged

umputun merged 2 commits into
umputun:masterfrom
TrevorBurnham:fix-649-wrapper-guard

Conversation

@TrevorBurnham

@TrevorBurnham TrevorBurnham commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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 exec leaves several claude pids 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 -c execs directly under the pane's claude. That worker now reports, and can clear a blocked glyph until the owner's next event. The adapter comment and site/docs.html state the surviving-process condition and name this as an accepted limitation.

Tests:

  • spawnedWorkerStaysSilent and runtimeHostedAgentIsCountedThroughArgv1 now interpose the shell a real tool call has, since a directly adjacent same-name pair is now read as a launcher chain.
  • New: nonExecLauncherChainCountsAsOneAgent and workerUnderLauncherChainStaysSilent.

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 compiled posix_spawn launcher (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.

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
@TrevorBurnham
TrevorBurnham marked this pull request as ready for review September 25, 2026 11:46

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@TrevorBurnham

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed that /bin/sh -c execs a single command. Updated both lines in d711563: the adapter comment now makes a surviving process between worker and spawner the condition and names the direct-child hook case as accepted, and the guide qualifies the silence to workers with a shell still between them.

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@umputun
umputun merged commit 27a348a into umputun:master Sep 26, 2026
7 checks passed
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.

Agent status hooks stay silent when claude is launched through a non-exec wrapper

2 participants