/agent-traffic-control:subagent-external-wait-orchestrator-takeoverfrom agent-traffic-control
Avoid orchestrator-budget burn when a subagent's main work is done but it's still polling an external event (CI completion, auto-deploy GHA workflow, Cloud Build, gcloud run revision rollout, long-running test suite, etc.). Use when: (1) you've dispatched a subagent with a final-step instruction like "verify auto-deploy" / "wait for CI green" / "poll until revision active", (2) the subagent has already done its substantive work (PR merged, artifact built) and is now in a polling loop, (3) you notice repeated `<task-notification>` events from that agent with `tool_uses: 0` and short `duration_ms` (a few seconds each) — each cycle says "still waiting" or "still in progress" with zero forward progress, (4) each notification forces the orchestrator to spend a turn responding (often dozens of these before the external event completes). The subagent isn't broken — it's doing what you asked — but the polling work belongs to the ORCHESTRATOR, not a subagent. Captures the takeover pattern: dispatch the subagent for the substantive work only (with explicit "do NOT poll for deploy verification, return after merge"), then the orchestrator runs a one-shot CronCreate scheduled to fire after the expected external-event duration to verify and close out. Sister to `schedule-poll-orchestrator-pattern` (different layer: that one is for fully-scheduled multi-track workflows, this one is for single-subagent in-session orchestration).
Trending skills
7-day visitors to each skill page
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You dispatch a subagent with a brief that includes both substantive work AND a final verification step gated on an external event:
"1. Implement … 2. Open PR … 3. Merge … 4. Verify auto-deploy: poll GHA workflow +
gcloud run revisions listuntil new revision is active."
Step 4 is wait work — the subagent has nothing to compute, only to wait and check. The harness keeps the agent task open during this wait, and each heartbeat / external signal wakes the agent for a tiny no-op cycle:
status: completed · tool_uses: 0 · duration_ms: 2000 · result: "Still polling."
status: completed · tool_uses: 0 · duration_ms: 2200 · result: "In progress."
status: completed · tool_uses: 0 · duration_ms: 1800 · result: "Continuing to wait."
... × 10-20 ...
Each cycle costs:
The orchestrator's response cost dwarfs the subagent's polling cost. Over a 13-minute Cloud Build wait, this can be ~10-20 orchestrator turns of "still polling, will report when done" — a non-trivial budget tax for zero work.
ALL of the following:
run_in_background: true)<task-notification> events from that agent with:
status: completedtool_uses: 0duration_ms (1-30s)result saying some variant of "still polling / in progress / waiting"The earlier in the wait you notice this, the more orchestrator budget you save by taking over.
The brief in the section above at least asks for the polling. The commoner and more expensive case is a line you wrote to stop an agent doing something, which it reads as an instruction to stand and watch:
"Arm auto-merge and wait."
What that meant: do not fire gh pr update-branch; let GitHub land it when the checks
pass. What it was read as: poll until the pull request merges.
Measured in one night: five agents did exactly that. One returned meow~ three
times having spent 300,000 tokens; another spent 355,000; a third reported
individual CI legs going green, one at a time, as though that were progress. Their
findings had been written into the pull request body the whole time — the work was
finished before the waiting started, and every token after that bought nothing.
Worse than the tokens: a polling agent emits notifications that look like progress. A stalled agent is at least quiet. This one produces a steady stream of plausible status lines, so each notification costs the orchestrator a wake to discover that nothing happened — and the fleet looks busy while it is idle.
The fix is two separate instructions, because one sentence cannot carry both. They are about different things and merging them is what created the ambiguity:
1. REPORT IMMEDIATELY after arming auto-merge. Your findings go in the PR body
before you arm. Do not wait for checks, do not wait for the merge, do not
report merge status — that is the orchestrator's job.
2. NEVER fire `gh pr update-branch` while a run is in progress on that branch.
Line 1 is what to do; line 2 is what not to do. Write both, and never write a prohibition whose verb ("wait", "hold off", "leave it alone") could be read as an activity.
And check that the wait is even necessary. In this case the deliverable — the findings — was already durable in the PR body. An agent waiting to report something it has already reported is the purest form of this bug.
Two adjacent failures worth telling apart when you write the brief:
orchestrator-rule-too-strict-stalls-agent-silently.merge-queue-thrash-stop-inflow-and-open-prs-as-drafts.In any subagent brief that includes external-event verification, replace the "poll until done" step with EITHER:
Option 1 — Subagent returns after the artifact is shipped, orchestrator verifies:
9. `gh pr merge --squash --delete-branch <PR#>`
10. **Return immediately** with the merge commit SHA. Do NOT wait for the
auto-deploy GHA workflow or Cloud Run revision rollout — the
orchestrator handles that verification.
Then the orchestrator schedules a one-shot CronCreate for the expected duration (e.g., 4 minutes after merge for a typical Cloud Build) to verify:
CronCreate(
cron="<one-shot expression for now+4min>",
prompt="Verify auto-deploy for PR #N: gh run view <run-id>; gcloud run revisions list ...",
recurring=False
)
Option 2 — Subagent uses gh pr checks --watch (single blocking call):
8. `gh pr checks <PR#> --watch` — this blocks until CI conclusion (single
tool call, no polling loop).
9. If green, merge.
gh pr checks --watch is a single blocking subprocess that doesn't return
until CI completes. The subagent makes ONE tool call and waits inside that
call. The harness sees one long-running tool, not dozens of short ones.
If a subagent is already in a zero-tool-use polling loop:
For the common Cloud-Run-via-GHA-pull_request:closed deploy verification:
# Verify auto-deploy completed for a merged PR.
# Run this from a one-shot CronCreate ~4 min after merge.
PR_NUMBER=$1
REPO=$2
SERVICE=$3
REGION=${4:-us-central1}
# Find the workflow run by name (NOT by squash SHA — that's a different SHA
# than the synthesized merge ref the workflow ran on)
RUN_ID=$(gh run list --repo "$REPO" \
--workflow "Auto-deploy pulse on PR merge" \
--limit 5 --json databaseId,status,createdAt \
--jq '[.[] | select(.status != "skipped")][0].databaseId')
# Check workflow conclusion
gh run view "$RUN_ID" --repo "$REPO" --json status,conclusion
# Confirm new revision is active
gcloud run revisions list --service "$SERVICE" --region "$REGION" \
--limit 3 --format='table(name,active,createTime)'
After applying takeover:
Compare to without takeover: 10-20 turns × N notifications.
S156 Track C orchestration (2026-05-08):
gcloud run revisions list"<task-notification> events to orchestrator: "Still running.",
"Continuing to wait.", "Auto-deploy still in progress.", etc.CronCreate at +4min
(17 18 8 5 *) with a self-contained verify prompt, then stopped
responding to subagent notifications. The cron fired once at 18:17,
did gh run view 25569007030 + gcloud run revisions list, confirmed
revision 00048-jds active, posted final summary, exited.The subagent's ~10 zero-tool-use micro-cycles cost the subagent itself ~1KB of context — negligible. The orchestrator-side cost was the real bug.
schedule-poll-orchestrator-pattern. This skill is the in-session
single-subagent variant.gh pr checks --watch is a much underused alternative to polling loops.
When the subagent's wait is on CI specifically (not deploy), prefer the
single-blocking-call form.WORKFLOW_RUN notifications you
could subscribe to instead of polling, but in-session orchestrator
context can't easily receive those — cron-based fire-time approximation
is usually the practical answer.schedule-poll-orchestrator-pattern — its own plugin in the
wan-huiyan-overnight-workflows marketplace, not here (cron-fired multi-track
variant; complementary, not redundant)subagent-reports-complete-but-pr-unmerged (related: gap
between agent status and actual PR state)superpowers:dispatching-parallel-agents (when to choose subagent
dispatch in the first place)gh pr checks --watch
blocks until CI conclusion in a single subprocess callWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verifyDisarming auto-merge on a PR whose agent is still running does not hold it —
the agent re-arms within minutes and the PR merges, because arming is a step in
the agent's brief and disarming is not an instruction to the agent at all. Use
when: (1) you want to STOP a pull request from merging that an agent opened and
armed, for review, for a rethink, or because it is landing into a queue you are
trying to drain; (2) a PR you disarmed merged anyway; (3) you are telling agents
which PRs are on hold and want the hold to be enforced rather than announced;
(4) you are about to run `gh pr merge --disable-auto` and have not decided what
to do about the agent. The order is KILL THE AGENT FIRST, THEN DISARM, THEN
VERIFY the disarm by reading `autoMergeRequest` back — a disarm you did not read
back is not a hold. The stronger form needs no ordering at all: convert the PR
to a draft with `gh pr ready --undo`. A draft cannot merge whatever any agent
does to it, so the hold survives an agent you missed, an agent that restarts,
and an agent you did not know about.
/batch-member-cites-a-path-only-a-non-member-addsYou wrote something correct that the default reader cannot reach: a batch member citing a
path only a NON-member adds, or a rule, ruling or ledger sitting on an unlanded branch.
/batch-merge-subject-is-not-evidence-a-member-landedYou are about to close, delete the branch of, or mark as landed a pull
request because a batch, roll-up or merge-train commit on the target branch
names it in the subject line, and because the member's own commits all
predate that merge by wall clock. Neither of those is evidence. A batch
branch is assembled at some moment BEFORE it merges, so anything the member
pushed after assembly is outside it, and the subject records INTENT at
assembly time rather than CONTENT at merge time. Use before closing a
member, when an ancestry check against a squashed batch says no, or when a
member's branch still shows commits ahead of the target. Compare file
content against the target branch instead, expecting exactly one legitimate
difference: the shared aggregate file every member appends to.
/check-a-stale-branch-is-not-undoing-newer-main-workA branch built on an out-of-date main is about to merge, or has merged, and may undo work
that landed since. Use when a green, conflict-free PR deletes files you never touched,
newer values or a whole redesign vanish after a sibling PR merged, rows of a shared ledger
(tracker, registry, CHANGELOG) disappear or revert, or when `git diff main...HEAD` or a
reviewer says your small PR touches dozens of files you did not change.
/ci-leg-skipping-moves-minutes-it-does-not-remove-themYou are about to propose, price or approve a CI cost saving that works by
making a job or matrix leg SKIP on pull requests — a path filter, a safe
list, a changed-files gate, an exemption list. Check first whether the
pipeline runs a complement or backstop on merge, on push, or nightly:
many do, and then the legs a pull request skipped are exactly the legs some
later run executes, so a branch that goes green once and merges bills the
same total either way and the wall clock does not move at all. Use when
pricing a filter change, when a percentage saving is quoted with no basis,
or when choosing between filtering legs and batching pull requests. The
question that separates money from bookkeeping is whether the change
removes RUNS or merely moves LEGS.
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control