test(experiment): repair relationship discovery result handling
This commit is contained in:
@@ -389,20 +389,12 @@ async function executeLive() {
|
||||
|
||||
console.log(`Model response received in ${elapsedMs}ms`);
|
||||
|
||||
// Parse the JSON output
|
||||
let parsedResult;
|
||||
try {
|
||||
const jsonMatch = raw.match(/\{[\s\S]*\}/);
|
||||
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);
|
||||
// Provider returns a parsed JavaScript object via recoverJson().
|
||||
// Do NOT regex-extract — the result is already structured.
|
||||
const parsedResult = typeof raw === "object" && raw !== null ? raw : (() => {
|
||||
console.error("Provider returned unexpected type (expected parsed object):", typeof raw);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
|
||||
// Validate output contract
|
||||
const errors = validateRelationshipOutput(parsedResult);
|
||||
|
||||
Reference in New Issue
Block a user