/agent-traffic-control:workflow-standalone-schema-agent-crash-and-args-stringfrom agent-traffic-control
Two failure modes that crash an entire dynamic Workflow (the Workflow tool / multi-agent orchestration scripts) and discard all completed agents' work. Use when: (1) a workflow fails with "Error: agent({schema}): subagent completed without calling StructuredOutput (after 2 in-conversation nudges)" — caused by a STANDALONE/terminal `await agent(prompt, {schema})` that is NOT inside parallel()/pipeline(), so the throw propagates and fails the whole run even though the other agents succeeded; (2) (caller error; the Workflow tool now documents passing real JSON values) a workflow fails immediately with "TypeError: undefined is not an object (evaluating 'P.candidates.map')" or args being a string — caused by the `args` global arriving as a JSON STRING in the script, not a parsed object. Covers guarding standalone schema agents (try/catch, parallel wrapper, or schema-less), defensive JSON.parse of args, and recovering a crashed run cheaply via resumeFromRunId (completed agents return cached).
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.
A dynamic Workflow (the Workflow tool's JS orchestration script) can run dozens of expensive
subagents and then lose the entire run to a single late failure — discarding all the completed
agents' work — because of two non-obvious script-level fragilities. Both cost a failed launch each;
the second can throw away a near-complete, six-figure-token run on one agent's hiccup.
Error: agent({schema}): subagent completed without calling StructuredOutput (after 2 in-conversation nudges)
Symptom: many agents ran (high agent_count / subagent_tokens), but status: failed and the
workflow returned nothing. The culprit is almost always a standalone const x = await agent(prompt, {schema})
(e.g. a final "critic"/"synthesis" step) that is NOT wrapped in parallel() or pipeline().args.filter/args.map in the script"). Fix first by passing a real array/object. The run fails in ~10ms at the first line touching args, with
TypeError: undefined is not an object (evaluating 'P.candidates.map'), X.map is not a function
(e.g. SESSIONS.map is not a function when const SESSIONS = args), or any args.<field> access.
The args you passed as a JSON object/array reached the script as a JSON string, so args.map/args.foo is invalid.
Best fix when the work-list is fixed/known at author time: skip args entirely — embed the list as a literal
(const SESSIONS = [ {...}, ... ]) in the script body. (Confirmed 2026-06-06: a 22-element array passed inline as
args arrived as a string → SESSIONS.map is not a function; embedding the literal fixed it on relaunch — 0 agents
had run, so a clean re-launch lost nothing.) Otherwise parse defensively: const a = typeof args === 'string' ? JSON.parse(args) : args.agent(prompt, {schema}) is contractually required to return a schema-valid object, so it throws
if the subagent never calls StructuredOutput. Inside parallel(thunks) / pipeline(...) a thrown
thunk is caught and resolves to null (the run survives). But a bare await agent(...) propagates
the throw to the top level and fails the whole workflow — including all the agents that already finished.
Guard every standalone schema-bearing agent. Any of:
// Option 1 — schema-less (most robust for a single synthesis/critic step; you read the prose)
let critic
try { critic = await agent(prompt, { label: 'critic', phase: 'Critic' }) } // no schema -> returns text, can't fail this way
catch (e) { critic = 'CRITIC_FAILED: ' + String(e) }
// Option 2 — keep the schema but make it non-fatal
const [critic] = await parallel([() => agent(prompt, { schema: CRITIC_SCHEMA })]) // failure -> null, run survives
// Option 3 — explicit guard, keep schema
let critic = null
try { critic = await agent(prompt, { schema: CRITIC_SCHEMA }) } catch (e) { critic = { error: String(e) } }
Rule of thumb: fan-out phases (parallel/pipeline) are already null-tolerant; standalone/terminal agent() calls are not — guard them. A late critic should never be able to discard an expensive upstream fan-out.
You do not have to redo the completed agents. Edit the persisted script file (the launch result prints
its Script file: path) to add the guard, then resume:
Workflow({ scriptPath: "<that path>", resumeFromRunId: "<the failed run's Run ID>", args: <same args> })
Completed agents with unchanged (prompt, opts) return cached instantly; only the edited call
(e.g. the now-guarded critic) re-runs. Pass byte-identical args so the cached agents' prompts hash-match.
If the ONLY thing that failed was a late synthesis/critic agent and you just want the upstream
fan-out's results (e.g. to synthesize them yourself in the orchestrator), you don't need resume at
all — the completed agents' schema-validated results are already persisted in the run's
journal.jsonl. The launch result prints a Transcript dir: (…/subagents/workflows//);
journal.jsonl there has one line per agent lifecycle event: {type:"started",…} then
{type:"result", agentId, result:<the validated object>}. Extract the result payloads directly:
# each successful schema agent emits a {"type":"result", "result": <object>} line
cat "<transcript-dir>/journal.jsonl" | python3 -c '
import json,sys
for line in sys.stdin:
o=json.loads(line)
if o.get("type")=="result": print(json.dumps(o["result"]))
'
A failed terminal agent shows only a started event (no result) — that is exactly the one that
threw. So N parallel agents succeeded, 1 synthesis failed ⇒ journal.jsonl has N result lines you
can use immediately. This is cheaper than resumeFromRunId when you don't actually need the synthesis
re-run — just pull the N findings and synthesize inline. (Verified 2026-06-05: a 4-reviewer plan-review
whose 5th synthesis agent hit the StructuredOutput error — all 4 reviewers' findings were intact in
journal.jsonl, recovered + synthesized by hand, zero re-run.)
Make the script tolerate args arriving as a string:
const P = (typeof args === 'string') ? JSON.parse(args) : args
Put this as the FIRST line that consumes args. (Passing a large object via the args parameter can
reach the sandboxed script JSON-encoded rather than as a live object; the defensive parse is cheap and
removes the dependency on how the harness marshals it.)
return {...} and status: completed; the guarded
agent's value is either its result or your fallback sentinel — not a crash.args.<field> access; P is an object with the expected keys.agent_count shows the cached agents (fast/instant) and only the changed
agent does real work.A 17-agent verification workflow (13 parallel classifiers + 3 adversarial + 1 critic) ran ~18 min and
~1M tokens, then failed with the StructuredOutput error — the final const critic = await agent(prompt, {schema: CRITIC_SCHEMA}) threw because that one agent never emitted structured output. The 16 parallel
agents had succeeded but their work was discarded. Fix: made the critic schema-less + try/catch, then
Workflow({scriptPath, resumeFromRunId, args}) — the 16 returned cached, only the critic re-ran (~1 min),
and the full {classified, adversarial, critic} returned. (A separate first launch had already failed
Mode-B with P.candidates.map undefined → fixed with the typeof args === 'string' ? JSON.parse guard.)
parallel()/pipeline() phases and any
single standalone aggregator/critic is guarded — that ordering means a terminal failure costs one
agent, never the whole fan-out.return the raw per-agent results (the orchestrator script returns the
parallel() array) and do the dedup/merge/verdict yourself in the main loop. You almost always have
the context to synthesize N structured findings, and it removes the single most common crash surface.
(Verified 2026-06-05: the retry of a failed plan-review used exactly this shape — return reviews from
the parallel phase, synthesize in the orchestrator — and completed cleanly.)claude-code-workflow-subagent-tokens-nested-undercount (a different Workflow gotcha —
token accounting in nested workflows).agent(prompt, {schema}) returns the validated object and retries on
mismatch; parallel()/pipeline() catch per-thunk throws and resolve to null; resume via
resumeFromRunId returns cached results for unchanged (prompt, opts).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control118 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.