Repository navigation
fix(server): workflow runs say why they failed and accept the growth shapes judges write - #21
Merged
Merged
Conversation
…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>
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(threadmcp:launch:4cf63db4…, runhaiku-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, int3_workflow_status, or in the parent's wake. The growth decoder requiredaddAgents[i].keyandinput. 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.
finishstep now carries anerror.workflowResultincludes it, so it shows in the result JSON and in the wake, which inlines the result.resultof the row it blames.t3_workflow_statusrebuilds it from that row.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:onExhaustedisfail.[failed]. Use task_status…. It now names the blamed row's error before that hint (Orchestrator.ts, a few lines).blamedLaunch()picks the agent that failed. If no agent failed, it picks the judge whose result ended the run. That row is markedfailed, with the run's error as itsresult. Web Lineage (theWorkflowMemberRowtooltip,member.result ?? member.error) and mobile (workflowMemberDetail().error) already show a failed member's error fromagent.resultthrough client-runtime'sworkflowMembersToRuntime, so no client code changed. Before this,toRownever setresult, 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'sfix.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 stringtaskreplaces the template's task. Without atask, the template's task runs withinput.{{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.delegate_task's prompt cap) the agent fails before it starts, and the run fails withround 2 rewriter-1-0: failed: Its task renders to more than 120000 bytes.addAgents/rerun, unknownrerunstage, a missing result, and a non-object result.3. Tool text.
addAgents:[{key,template,input,stage?}]becomesaddAgents:[{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 inworkflowRun.test.tsand 2 of 18 inWorkflowRuns.test.tsfailed.grows from the shapes a judge naturally writes: no key, a task instead of input(new):draft.rewriter-1-0#2in round 2 and runs it with the taskRewrite only line 1 .... The run completes.taskresolves{{draft.poet}}, and that an entry with onlyinputuses the template's task.crashSweepcrashes at, and instead of, every persist, including the one between the judge's result and the grown record. Every resume matches the clean run, anddraft.rewriter-1-0#2is 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 carryround 1 critic: addAgents[0]: unknown template "rewiter":t3_workflow_status;{state: "failed", result: error};Mutation check.
wf11/mutations.mjsapplies one fault at a time and restores the file afterwards. Each fault turns its test red:says why…says why…grows from the shapes…taskis ignoredgrows from the shapes…Bytes
AgentContextBudget.test.ts)shows a judge's grown agents…,keeps every workflow row update within 2 KB…)"), 1,994 B (界).Gate
gate.sh fork/wf/integration: green.apps/serverandpackages/contracts.workflowRun.test.tsandWorkflowRuns.test.ts: 43/43.Beyond the gate:
AgentContextBudget,WorkflowRunRows,McpHttpServerandDelegatedCompletionDelivery: 65/65.subagentRuntimeandthreadSubagents: 33/33.evals/mcp-tool-use/run.test.ts(grader and spec decoding): 411/411.Not run
mcp-tool-useevals: this worktree has no eval API keys.resultas its error, and the service test asserts that row.Review round 1 (Codex: CHANGES_REQUESTED), fixed in
66f78bdc99Repro:
probes/review-pr21-ba19.mjs. After the fix:wf11/review-pr21-after.mjs, the same scenarios with the assertions flipped to the fixed behavior.{{draft.poet}}rendered a 64 KiB result into 64 MiB and passed it toport.start. A judge task could also read{{private.secret}}from a stage the judge never saw.private.secretstays literal.bounds a judge's task: it sees only what the judge saw, and never renders oversized.workflowRun.erroris gone. Failure updates measure 1,978, 1,977 and 1,994 B.keeps every workflow row update within 2 KB on the wire…(2,275 B for ASCII on the old code).gate.sh fork/wf/integration: green. Lint 6 files, 0 diagnostics; typecheckapps/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