scai 0.1.125 → 0.1.126
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/agents/finalPlanGenStep.js +22 -27
- package/package.json +1 -1
|
@@ -18,44 +18,38 @@ export const finalPlanGenStep = {
|
|
|
18
18
|
context.analysis || (context.analysis = {});
|
|
19
19
|
(_a = context.analysis).planSuggestion || (_a.planSuggestion = {});
|
|
20
20
|
(_b = context.analysis.planSuggestion).plan || (_b.plan = { steps: [] });
|
|
21
|
-
//
|
|
21
|
+
// Only allow actions in the FINALIZE group
|
|
22
22
|
const effectiveActions = PLAN_ACTIONS.filter(a => a.groups?.includes('finalize'));
|
|
23
23
|
const actionsJson = JSON.stringify(effectiveActions, null, 2);
|
|
24
24
|
const intentText = context.analysis.intent?.normalizedQuery ?? '';
|
|
25
25
|
const intentCategory = context.analysis.intent?.intentCategory ?? '';
|
|
26
|
+
// Simplified prompt — focus purely on allowed finalization actions
|
|
26
27
|
const prompt = `
|
|
27
28
|
You are an autonomous coding agent.
|
|
28
|
-
|
|
29
|
-
to
|
|
29
|
+
|
|
30
|
+
Your task is to produce a JSON plan for the FINALIZATION phase only.
|
|
31
|
+
Each step should describe a module to run to finalize the workflow and produce a response to the user.
|
|
30
32
|
|
|
31
33
|
Intent / task description:
|
|
32
34
|
${intentText}
|
|
33
35
|
|
|
34
|
-
If the intent indicates that no finalization is required, return an empty plan object with an empty "steps" array:
|
|
35
|
-
{ "steps": [] }
|
|
36
|
-
|
|
37
|
-
Allowed actions (finalize only):
|
|
38
|
-
${actionsJson}
|
|
39
|
-
|
|
40
36
|
Task category:
|
|
41
37
|
${intentCategory}
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
${
|
|
45
|
-
|
|
46
|
-
Existing relevant files:
|
|
47
|
-
${JSON.stringify(context.analysis.focus?.relevantFiles ?? {}, null, 2)}
|
|
48
|
-
|
|
49
|
-
⚡ Phase guidance:
|
|
50
|
-
- Actions are grouped into phases: info, transform, finalize.
|
|
51
|
-
- Only include finalize steps in this phase.
|
|
52
|
-
- Each step must include: "action", "targetFile" (optional), "description", "metadata"
|
|
39
|
+
Allowed actions (finalize only):
|
|
40
|
+
${actionsJson}
|
|
53
41
|
|
|
54
|
-
|
|
42
|
+
⚡ Important instructions:
|
|
43
|
+
- Only use actions listed in the allowed actions.
|
|
44
|
+
- Every plan must produce a user-facing response.
|
|
45
|
+
- Each step must include: "action", "targetFile" (optional), "description", "metadata".
|
|
46
|
+
- Do NOT invent new actions.
|
|
47
|
+
- Return strictly valid JSON.
|
|
55
48
|
|
|
49
|
+
Example format:
|
|
56
50
|
{
|
|
57
51
|
"steps": [
|
|
58
|
-
{ "action": "
|
|
52
|
+
{ "action": "finalAnswer", "targetFile": null, "description": "Generate final user-facing response.", "metadata": {} }
|
|
59
53
|
]
|
|
60
54
|
}
|
|
61
55
|
`.trim();
|
|
@@ -86,11 +80,11 @@ Return a strictly valid JSON plan:
|
|
|
86
80
|
groups: actionDef?.groups ?? ['finalize']
|
|
87
81
|
};
|
|
88
82
|
});
|
|
89
|
-
// Ensure at least one
|
|
90
|
-
if (plan.steps.
|
|
83
|
+
// Ensure at least one finalAnswer step if plan is empty
|
|
84
|
+
if (!plan.steps.some(s => s.action === 'finalAnswer')) {
|
|
91
85
|
plan.steps.push({
|
|
92
|
-
action: '
|
|
93
|
-
description: '
|
|
86
|
+
action: 'finalAnswer',
|
|
87
|
+
description: 'Generate final user-facing response summarizing results.',
|
|
94
88
|
metadata: {
|
|
95
89
|
routingConfidence: context.analysis?.routingDecision?.confidence ?? 0
|
|
96
90
|
},
|
|
@@ -106,10 +100,11 @@ Return a strictly valid JSON plan:
|
|
|
106
100
|
}
|
|
107
101
|
catch (err) {
|
|
108
102
|
console.warn('⚠️ Failed to generate final plan:', err);
|
|
103
|
+
// Fallback: always include finalAnswer
|
|
109
104
|
context.analysis.planSuggestion.plan.steps = [
|
|
110
105
|
{
|
|
111
|
-
action: '
|
|
112
|
-
description: '
|
|
106
|
+
action: 'finalAnswer',
|
|
107
|
+
description: 'Generate final user-facing response summarizing results.',
|
|
113
108
|
metadata: {
|
|
114
109
|
routingConfidence: context.analysis?.routingDecision?.confidence ?? 0
|
|
115
110
|
},
|