Skip to content

fix(server): workflow runs say why they failed and accept the growth shapes judges write - #21

Merged
EtanHey merged 3 commits into
wf/integrationfrom
wf/11-growth-errors
Oct 31, 2026
Merged

EtanHey merged 3 commits into
wf/integrationfrom
wf/11-growth-errors

Conversation

@EtanHey

@EtanHey EtanHey commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Size: M. About 190+/60− hand-written (workflowRun.ts, WorkflowRuns.ts, the wake fallback, the tool text), plus about 290+/15− in tests. No contract change.

Problem

A live demo ran a growing loop on dev env 00f21043 (thread mcp:launch:4cf63db4…, run haiku-growing-loop). The Haiku parent's judge returned this structured result, verbatim:

{"best":"...","best_score":6,"addAgents":[{"template":"rewriter","task":"Rewrite only line 1 ..."}],"rerun":["draft"],"done":false,"fix":"..."}

The run failed after round 1 with {"name":"haiku-growing-loop","status":"failed","stages":[{"id":"loop","exit":null,...}]}. No reason appeared in the result, in t3_workflow_status, or in the parent's wake. The growth decoder required addAgents[i].key and input. The judge sent {template, task}, so its growth was invalid and the run failed without saying so. Etan, watching: "something there failed, and it doesn't really tell me what."

Fix

1. A failed run says why, everywhere.

  • The runner's finish step now carries an error. workflowResult includes it, so it shows in the result JSON and in the wake, which inlines the result.
  • One copy on the wire. The row keeps the error once, as the result of the row it blames. t3_workflow_status rebuilds it from that row.
  • The error is cut to 200 JSON-encoded bytes on a code point boundary, so quotes and non-ASCII text can't push the run's last update past 2 KB. It reads as one of:
    • round 1 critic: addAgents[0]: unknown template "x": invalid growth.
    • round 1 a: invalid_output: $.verdict: required: an agent failed, with its status and result.
    • loop: not accepted in 2 rounds: onExhausted is fail.
  • Wake fallback. When a result is over the 16 KB inline cap, the wake used to say only [failed]. Use task_status…. It now names the blamed row's error before that hint (Orchestrator.ts, a few lines).
  • Row. blamedLaunch() picks the agent that failed. If no agent failed, it picks the judge whose result ended the run. That row is marked failed, with the run's error as its result. Web Lineage (the WorkflowMemberRow tooltip, member.result ?? member.error) and mobile (workflowMemberDetail().error) already show a failed member's error from agent.result through client-runtime's workflowMembersToRuntime, so no client code changed. Before this, toRow never set result, so failed agents showed no reason in either client.

2. Growth accepts the shapes models write. The strict decoder is replaced by parseGrowth. It is lenient but deterministic, and it returns either the growth or the reason it is invalid.

  • addAgents[i] is {template, key?, input?, task?, stage?}. Extra fields are ignored, like the live result's fix.
  • Missing key. The key is derived as <template>-<judge round>-<index>, e.g. rewriter-1-0. The template name is reduced to id characters. The key is a pure function of the persisted judge result, so dedup, findAgent, and resume all see the same key.
  • task. A string task replaces the template's task. Without a task, the template's task runs with input.
    • It resolves {{feedback}}, {{input.x}}, the repeat's own stages, and the stages its judge's own task reads. References to other stages stay literal, so a judge can't pull in output it never saw. Replacement stays single-pass.
    • Every task, spec-written or judge-written, is measured in bytes before it is built. Past 120,000 bytes (delegate_task's prompt cap) the agent fails before it starts, and the run fails with round 2 rewriter-1-0: failed: Its task renders to more than 120000 bytes.
  • Still fails, now with a reason: unknown template, non-object entry, bad explicit key, unknown stage, non-text task, non-object input, a non-list addAgents/rerun, unknown rerun stage, a missing result, and a non-object result.

3. Tool text. addAgents:[{key,template,input,stage?}] becomes addAgents:[{template,task?,input?,key?,stage?}]. To pay for it I changed "returns at once" to "returns now", removed the spaces in the {{…}} list, and changed "insert results" to "insert output".

Tests that failed first

I wrote these before any runner code. On fork/wf/integration, 5 of 25 in workflowRun.test.ts and 2 of 18 in WorkflowRuns.test.ts failed.

  • grows from the shapes a judge naturally writes: no key, a task instead of input (new):
    • The exact live judge result grows draft.rewriter-1-0#2 in round 2 and runs it with the task Rewrite only line 1 .... The run completes.
    • A second judge result checks that a task resolves {{draft.poet}}, and that an entry with only input uses the template's task.
    • crashSweep crashes at, and instead of, every persist, including the one between the judge's result and the grown record. Every resume matches the clean run, and draft.rewriter-1-0#2 is created exactly once.
  • says why a judge's invalid growth failed the run: result, status, wake and row (new, real orchestrator). The judge names an unknown template, and these all carry round 1 critic: addAgents[0]: unknown template "rewiter":
    • the result JSON and t3_workflow_status;
    • the critic's row, as {state: "failed", result: error};
    • the parent's wake text, which the test delivers as the continuation service would. The poet's long draft pushes the result past the inline cap, so this exercises the fallback.
  • Existing cases now also pin each error string:
    • the dry-vote and accepting-judge tables (six malformed growths, the missing result, and three non-object results);
    • the exhausted repeat;
    • a schema-failed agent;
    • the schema-failed judge's row and status.

Mutation check. wf11/mutations.mjs applies one fault at a time and restores the file afterwards. Each fault turns its test red:

Fault Caught by
The wake drops the error when the result is not inlined says why…
The row stops blaming the judge says why…
The derived key ignores the judge's round grows from the shapes…
A judge's task is ignored grows from the shapes…

Bytes

Budget Measured
MCP tool list (AgentContextBudget.test.ts) 47,106 B, unchanged (+0). The stack stays at +1,199 B over upstream, under the +1,200 cap.
Agent instructions +0 B
Per-update wire, ≤ 2 KB (shows a judge's grown agents…, keeps every workflow row update within 2 KB…) green. The wire test now also fails a 20-agent run with the longest possible error. Largest failure update: 1,978 B (ASCII), 1,977 B ("), 1,994 B (界).

Gate

gate.sh fork/wf/integration: green.

  • Lint: 7 files, 0 diagnostics. Fmt: clean.
  • Typecheck: apps/server and packages/contracts.
  • workflowRun.test.ts and WorkflowRuns.test.ts: 43/43.

Beyond the gate:

  • AgentContextBudget, WorkflowRunRows, McpHttpServer and DelegatedCompletionDelivery: 65/65.
  • client-runtime subagentRuntime and threadSubagents: 33/33.
  • evals/mcp-tool-use/run.test.ts (grader and spec decoding): 411/411.

Not run

  • The paid mcp-tool-use evals: this worktree has no eval API keys.
  • A live rerun of the demo on a real dev server, and before/after captures of the Lineage tooltip and the mobile detail. The row change is data only. Both clients already render a failed member's result as its error, and the service test asserts that row.

Review round 1 (Codex: CHANGES_REQUESTED), fixed in 66f78bdc99

Repro: probes/review-pr21-ba19.mjs. After the fix: wf11/review-pr21-after.mjs, the same scenarios with the assertions flipped to the fixed behavior.

  • MUST_FIX 1: unbounded, unscoped judge task.
    • Before: a 13,312 B task of repeated {{draft.poet}} rendered a 64 KiB result into 64 MiB and passed it to port.start. A judge task could also read {{private.secret}} from a stage the judge never saw.
    • Now: the agent never starts and the run fails with the reason above. private.secret stays literal.
    • Failed first: bounds a judge's task: it sees only what the judge saw, and never renders oversized.
  • MUST_FIX 2: failure update over 2 KB.
    • Before: the error was sent twice and clipped by characters, so failure updates measured 2,199 B (ASCII) and 2,963 B (Unicode).
    • Now: one copy, a 200-byte JSON budget, and workflowRun.error is gone. Failure updates measure 1,978, 1,977 and 1,994 B.
    • Failed first: the new failure cases in keeps every workflow row update within 2 KB on the wire… (2,275 B for ASCII on the old code).
  • Gate. gate.sh fork/wf/integration: green. Lint 6 files, 0 diagnostics; typecheck apps/server; 44/44. Budget, rows, HTTP-server and delegated-completion suites also pass: 109/109 with the two workflow suites.

Implementer: Claude Opus 5.5. Review rounds: 1.

🤖 Generated with Claude Opus 5.5 in T3 Code Nightly

…shapes judges write

A live Haiku run failed after round 1 with no reason anywhere: its judge
sent addAgents [{template, task}] without key or input, so the strict
growth decode rejected it silently.

- A failed run carries a short `error` (e.g. `round 1 critic:
  addAgents[0]: unknown template "x"`) in its result JSON, in
  t3_workflow_status, in workflowRun state, and in the parent's wake even
  when the result is too long to inline. The failed agent's row, or the
  judge that ended the run, shows it as a failed row with that error.
- addAgents entries are {template, key?, input?, task?, stage?}. A missing
  key derives as <template>-<judge round>-<index>, so dedup and resume
  stay deterministic; a task replaces the template's task and resolves
  {{...}}. Unknown templates, non-object entries and unknown rerun stages
  still fail, now with the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L Large coherent reviewed change, over 400 added lines labels Oct 31, 2026
EtanHey and others added 2 commits October 31, 2026 06:25
…in one update

Review round 1 (Codex) found two MUST_FIX defects in the growth-errors change:

- A judge-authored task could repeat {{draft.poet}} until a 64 KiB result
  rendered to 64 MiB, and it could read any completed stage, even ones its
  judge never saw. Every task is now measured before it is built (120,000
  bytes, delegate_task's prompt cap); past that the agent fails before it
  starts, and the run fails with that reason. A judge-authored task reads
  only the repeat's stages and those its judge's own task reads; other
  references stay literal. Replacement stays single-pass.
- The error was sent twice (blamed row and workflowRun.error) and clipped
  by characters, so failure updates reached 2,199 B (ASCII) and 2,963 B
  (Unicode). It is now kept once, on the blamed row, which status and the
  wake fallback read back, and cut to 200 JSON-encoded bytes on a code
  point boundary. The contract field is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The render budget only ran inside the reference loop, so a plain
oversized task reached delegate. Measure the literal bytes first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EtanHey
EtanHey merged commit 7231106 into wf/integration Oct 31, 2026
9 of 10 checks passed
@EtanHey
EtanHey deleted the wf/11-growth-errors branch November 2, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L Large coherent reviewed change, over 400 added lines vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant