Skip to content

Fail loud on unparseable triage output instead of dropping the batch#121

Open
thejesh23 wants to merge 1 commit into
vercel-labs:mainfrom
thejesh23:fix/deepsec-003
Open

Fail loud on unparseable triage output instead of dropping the batch#121
thejesh23 wants to merge 1 commit into
vercel-labs:mainfrom
thejesh23:fix/deepsec-003

Conversation

@thejesh23

Copy link
Copy Markdown

What changed

triageBatch now parses the model's verdict array through the same tolerant, fail-loud path the investigate/revalidate agents already use — parseAgentJsonArray (jsonrepair-backed) — instead of a bare JSON.parse in an empty catch. Genuinely unparseable output is dumped via writeParseFailureDebug and rethrown so the outer catch marks the batch failed. parseAgentJsonArray is exported from agents/shared.ts for reuse.

Why

The old code left verdicts = [] on any parse error, so a routine trailing-comma or truncated array silently lost the triage for the entire (up to 30-finding) batch while still printing Batch N/M: 0 triaged as success — indistinguishable from a clean "nothing to triage" run. agents/shared.ts already documents this exact failure mode for the investigate path ("a malformed response is otherwise indistinguishable from a clean 'found nothing' run") and guards against it; triage now matches that behavior.

Fixes #120

Verification

  • pnpm test passes (added regression tests: a trailing-comma array is recovered and triaged; a non-array reply surfaces a failed batch instead of "0 triaged". Both fail on main and pass with this change)
  • pnpm lint passes
  • pnpm knip passes
  • If this adds a matcher: n/a

Also ran pnpm -r build (typecheck) and pnpm test:bundle — both green.

Notes for reviewer

Minor malformations that jsonrepair can recover are now triaged rather than dropped; only genuinely unrecoverable output fails the batch (and writes a parse-error-revalidate-*.txt debug dump, consistent with the other agents). No change to the verdict-application logic itself.

triageBatch parsed the model's verdict array with a bare `JSON.parse`
wrapped in `try { … } catch {}`, leaving `verdicts = []` on any error.
A common trailing-comma or truncated array was therefore swallowed: the
loop ran zero times, every finding in the (up to 30-finding) batch stayed
un-triaged, and the batch was still reported as a success ("N triaged")
— indistinguishable from a clean "nothing to do" run.

Route triage through the same tolerant parse + fail-loud path the
investigate/revalidate agents already use: `parseAgentJsonArray`
(jsonrepair-backed) recovers minor malformations, and genuinely
unparseable output is dumped via `writeParseFailureDebug` and rethrown so
the outer catch marks the batch failed rather than silently empty.
`parseAgentJsonArray` is exported from agents/shared.ts for reuse.

Adds regression tests: a trailing-comma array is recovered and triaged; a
non-array reply surfaces a failed batch instead of "0 triaged".
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

@thejesh23 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

triage: unparseable model output is swallowed, dropping a whole batch's triage while reporting success

1 participant