agents-relay 2.0.122 → 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 +9 -11
- package/package.json +1 -1
package/dist/planner.js
CHANGED
|
@@ -538,20 +538,18 @@ export class AgentObjectivePlanner {
|
|
|
538
538
|
resolve(finalMessage);
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
catch (error) {
|
|
546
|
-
if (signal.aborted)
|
|
547
|
-
throw error;
|
|
548
|
-
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.`;
|
|
541
|
+
const parseAndCheck = (raw) => { const result = parsePlannerOutput(raw); validatePlannerResolutionMaterialization(context.tasks, result.next_tasks); return result; };
|
|
542
|
+
let response = await runAgent(prompt);
|
|
543
|
+
for (let retry = 0; retry <= 3; retry++) {
|
|
549
544
|
try {
|
|
550
|
-
return
|
|
545
|
+
return parseAndCheck(response);
|
|
551
546
|
}
|
|
552
|
-
catch (
|
|
553
|
-
|
|
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.`);
|
|
554
551
|
}
|
|
555
552
|
}
|
|
553
|
+
throw new Error('Planner correction exhausted');
|
|
556
554
|
}
|
|
557
555
|
}
|