fix(core): surface a failing step's output instead of discarding it
Defect #5 from the Nabis certification run. A failing step's output is usually the most useful thing in the run, and it was thrown away.
The problem
step-executor.ts persisted and logged output only when status === 'completed':
if (finalResult.status === 'completed' && this.deps.runId && finalResult.output) {
await this.deps.persistStepOutput?.(...);
}
So a step that produced a perfectly good answer which merely lacked the expected token wrote its result nowhere. All the operator saw:
Verification failed for "review-preq": output does not contain "PREQ: PASS"
— indistinguishable from "the agent returned nothing".
What it was actually hiding
That lane had written a considered rejection of a real memory-exhaustion DoS, ending PREQ: FAIL <reason>. It was recoverable only from a raw worker log under .agent-relay/team/worker-logs/. Three other review lanes had waved the same defect through as a non-blocking follow-up — so that discarded verdict was the single most valuable sentence the run produced.
I lost hours to this, having concluded from the message that the lane had returned empty output. It hadn't.
Changes
- Persist and log output for failed steps too, labelled
Output (FAILED)so it isn't mistaken for a pass.persistStepOutputnow takes the status and adjusts its wording. output_containsfailures quote what the step produced.describeOutputForFailurereports the length and trailing 400 chars — where a verdict marker would be — or saysThe step produced no output.One line that distinguishes "returned nothing" from "returned an answer that wasn't the token", which call for opposite responses.
Secret-scrubbing gap found along the way
Widening what reaches the channel is only safe if the scrubber covers the keys that actually appear here. It didn't:
LEAKED !! anthropic sk-ant-api03-…
LEAKED !! openai sk-proj-…
REDACTED openai legacy sk-…, slack xoxb-…, github ghp_…, relay rk_live_…
(?:sk|pk|rk|ak)[-_][a-zA-Z0-9]{20,} stops at the first hyphen, so sk-ant-api03-… matched only as far as ant. This is pre-existing and affects all step output posted to the channel today, not just the new failure excerpts — and Anthropic/OpenAI keys are the two most likely to show up in this codebase's agent output.
Body now allows -/_, with a \b guard so prose ending in sk- (ask-…, task-…) isn't redacted. Verified across six key shapes and three prose negatives.
Verification
- 903/903 tests (14 new),
tsc --noEmit0 errors, build OK - One existing assertion updated for the new 4-argument
persistStepOutput
🤖 Generated with Claude Code
Summary by cubic
Surfaces failed step output and quotes it in verification errors. Previously only completed steps persisted and posted output; now failed steps also persist and post output labeled “Output (FAILED)”. Secret scrubbing now redacts entire keys, preventing partial leaks.
- Runner: failure paths carry and persist output.
executeDeterministicStepreturns captured output on failure;markStepFailedwritesrow.outputand callspersistStepOutput(..., 'failed').persistStepOutput(runId, stepName, output, status?)labels logs/channel (“Output (FAILED)”) and uses “Step failed — output written to disk” when the scrubbed preview is empty. - Verification:
output_containsfailures include an excerpt of the echo‑stripped tail viadescribeOutputForFailure(stripInjectedTaskEcho(...)), usingscrubDiagnostic(secrets redacted; ANSI/system‑reminder stripped; JSON preserved). - Messenger: adds
scrubDiagnostic, refactors ANSI/system‑reminder stripping, and tightens the vendor key regex to allow short-/_prefix segments only before a long alphanumeric run and to consume trailing[-_]*so the whole key is redacted (no partial leaks). - Tests updated; 911/911 passing.
Rollout
- No migration required; the fourth
persistStepOutputparameter is optional. - If you grep channel messages/logs, update patterns to accept “Output (FAILED)” and “Step failed — output written to disk.”