agents-relay 2.0.123 → 2.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/planner.js +8 -11
- package/package.json +1 -1
package/dist/planner.js
CHANGED
|
@@ -539,20 +539,17 @@ export class AgentObjectivePlanner {
|
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
541
|
const parseAndCheck = (raw) => { const result = parsePlannerOutput(raw); validatePlannerResolutionMaterialization(context.tasks, result.next_tasks); return result; };
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return parseAndCheck(first);
|
|
545
|
-
}
|
|
546
|
-
catch (error) {
|
|
547
|
-
if (signal.aborted)
|
|
548
|
-
throw error;
|
|
549
|
-
const correction = `${prompt}\n\n## Format correction (one retry only)\nYour previous final response was not valid Planner JSON. Error: ${error instanceof Error ? error.message : String(error)}\nPrevious response (possibly truncated):\n${first.slice(0, 12000)}\nReturn exactly one valid JSON object conforming to the Planner contract. No prose, no second JSON object.`;
|
|
542
|
+
let response = await runAgent(prompt);
|
|
543
|
+
for (let retry = 0; retry <= 3; retry++) {
|
|
550
544
|
try {
|
|
551
|
-
return parseAndCheck(
|
|
545
|
+
return parseAndCheck(response);
|
|
552
546
|
}
|
|
553
|
-
catch (
|
|
554
|
-
|
|
547
|
+
catch (error) {
|
|
548
|
+
if (signal.aborted || retry === 3)
|
|
549
|
+
throw new Error(`Planner validation failed after ${retry} corrections: ${error instanceof Error ? error.message : String(error)}`);
|
|
550
|
+
response = await runAgent(`${prompt}\n\n## Fix validation error (correction ${retry + 1} of 3)\n${error instanceof Error ? error.message : String(error)}\nPrevious JSON:\n${response.slice(0, 12000)}\nReturn exactly one complete Planner JSON object. Correct all schema, title, resolution, and dependency requirements; do not remove valid work or bypass safeguards.`);
|
|
555
551
|
}
|
|
556
552
|
}
|
|
553
|
+
throw new Error('Planner correction exhausted');
|
|
557
554
|
}
|
|
558
555
|
}
|