test(experiment): repair relationship discovery result handling

This commit is contained in:
2026-08-19 16:14:50 +01:00
parent 8fb284c374
commit 4687226bd8
@@ -389,20 +389,12 @@ async function executeLive() {
console.log(`Model response received in ${elapsedMs}ms`); console.log(`Model response received in ${elapsedMs}ms`);
// Parse the JSON output // Provider returns a parsed JavaScript object via recoverJson().
let parsedResult; // Do NOT regex-extract — the result is already structured.
try { const parsedResult = typeof raw === "object" && raw !== null ? raw : (() => {
const jsonMatch = raw.match(/\{[\s\S]*\}/); console.error("Provider returned unexpected type (expected parsed object):", typeof raw);
if (jsonMatch) {
parsedResult = JSON.parse(jsonMatch[0]);
} else {
throw new Error("No JSON object found in response");
}
} catch (e) {
console.error("Failed to parse model output as JSON:", e.message);
console.error("Raw response:\n", raw);
process.exit(1); process.exit(1);
} })();
// Validate output contract // Validate output contract
const errors = validateRelationshipOutput(parsedResult); const errors = validateRelationshipOutput(parsedResult);