Evals contains-json assertion is greedy: any later bracket swallows the fragment, so output with a markdown link after the JSON fails
Observed on 7.54.0.
What
// skills/Evals/Tools/Assertions.ts:137
passed = /[{[][\s\S]*[}\]]/.test(output) && (() => {
const m = output.match(/[{[][\s\S]*[}\]]/);
if (!m) return false;
try { JSON.parse(m[0]); return true; } catch { return false; }
})();
[\s\S]* is greedy, so the match runs from the first opening bracket to the last closing bracket anywhere in the output. Any later ] or } — a markdown link, a citation index, a second object — is swallowed into the fragment and JSON.parse fails.
Repro
"Result: {\"status\":\"ok\"}\n\nSee [the docs](https://example.dev) for details."
-> {"passed":false,"score":0,"reason":"no valid JSON fragment"}
"Here is the payload: {\"a\":1} and the id is item[3]."
-> {"passed":false,"score":0,"reason":"no valid JSON fragment"}
Expected
passed: true in both: each output plainly contains a valid JSON fragment.
Why it matters
A case asserting the agent emitted JSON scores 0 whenever the model also wrote a markdown link — which is most of the time. The runner reports that as a real regression.
The shipped self-test only covers prefix {"a":1} suffix, which has no trailing bracket, so it passes and hides the bug.
Fix sketch
Iterate candidate spans (each opening bracket paired with each closing bracket, shortest first) and pass on the first that JSON.parses, instead of testing one greedy match. A brace/bracket-balance scan from the first opening bracket is the cheaper equivalent.
This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.
Confirmed — the bracket match ran to the LAST ] in the output, so any trailing content (a markdown link, extra prose) after valid JSON broke the assertion. Reproduced with your exact repro strings. Replaced with a balance-scanning fragment finder.
Environment: ThinkPad, Ubuntu 24.04.4 LTS, Ryzen AI 9 HX PRO 370, Bun 1.3.11.
Thanks @Bowlerjim. Confirmed: the greedy match ran to the last closing bracket in the output. contains-json now scans balanced spans, ported from your PR #2196, so a markdown link after the JSON no longer fails the assertion (skills/Assay/Tools/Assertions.ts; the Evals skill is now named Assay). Next release carries it.