Skip to content

Commit d7c3337

Browse files
committed
refactor(auto-mode): Enhance revision prompt customization and task format validation
- Updated the revision prompt generation to utilize a customizable template, allowing for dynamic insertion of plan version, previous plan content, user feedback, and task format examples. - Added validation to ensure the presence of a tasks block in the revised specification, with clear instructions on the required format to prevent execution issues. - Introduced logging for scenarios where no tasks are found in the revised plan, warning about potential fallback to single-agent execution.
1 parent c848306 commit d7c3337

File tree

2 files changed

+81
-16
lines changed

2 files changed

+81
-16
lines changed

apps/server/src/services/auto-mode-service.ts

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,21 +4597,54 @@ This mock response was generated because AUTOMAKER_MOCK_AGENT=true was set.
45974597
planVersion,
45984598
});
45994599

4600-
// Build revision prompt
4601-
let revisionPrompt = `The user has requested revisions to the plan/specification.
4602-
4603-
## Previous Plan (v${planVersion - 1})
4604-
${hasEdits ? approvalResult.editedPlan : currentPlanContent}
4605-
4606-
## User Feedback
4607-
${approvalResult.feedback || 'Please revise the plan based on the edits above.'}
4600+
// Build revision prompt using customizable template
4601+
const revisionPrompts = await getPromptCustomization(
4602+
this.settingsService,
4603+
'[AutoMode]'
4604+
);
46084605

4609-
## Instructions
4610-
Please regenerate the specification incorporating the user's feedback.
4611-
Keep the same format with the \`\`\`tasks block for task definitions.
4612-
After generating the revised spec, output:
4613-
"[SPEC_GENERATED] Please review the revised specification above."
4614-
`;
4606+
// Get task format example based on planning mode
4607+
const taskFormatExample =
4608+
planningMode === 'full'
4609+
? `\`\`\`tasks
4610+
## Phase 1: Foundation
4611+
- [ ] T001: [Description] | File: [path/to/file]
4612+
- [ ] T002: [Description] | File: [path/to/file]
4613+
4614+
## Phase 2: Core Implementation
4615+
- [ ] T003: [Description] | File: [path/to/file]
4616+
- [ ] T004: [Description] | File: [path/to/file]
4617+
\`\`\``
4618+
: `\`\`\`tasks
4619+
- [ ] T001: [Description] | File: [path/to/file]
4620+
- [ ] T002: [Description] | File: [path/to/file]
4621+
- [ ] T003: [Description] | File: [path/to/file]
4622+
\`\`\``;
4623+
4624+
let revisionPrompt = revisionPrompts.taskExecution.planRevisionTemplate;
4625+
revisionPrompt = revisionPrompt.replace(
4626+
/\{\{planVersion\}\}/g,
4627+
String(planVersion - 1)
4628+
);
4629+
revisionPrompt = revisionPrompt.replace(
4630+
/\{\{previousPlan\}\}/g,
4631+
hasEdits
4632+
? approvalResult.editedPlan || currentPlanContent
4633+
: currentPlanContent
4634+
);
4635+
revisionPrompt = revisionPrompt.replace(
4636+
/\{\{userFeedback\}\}/g,
4637+
approvalResult.feedback ||
4638+
'Please revise the plan based on the edits above.'
4639+
);
4640+
revisionPrompt = revisionPrompt.replace(
4641+
/\{\{planningMode\}\}/g,
4642+
planningMode
4643+
);
4644+
revisionPrompt = revisionPrompt.replace(
4645+
/\{\{taskFormatExample\}\}/g,
4646+
taskFormatExample
4647+
);
46154648

46164649
// Update status to regenerating
46174650
await this.updateFeaturePlanSpec(projectPath, featureId, {
@@ -4663,6 +4696,26 @@ After generating the revised spec, output:
46634696
const revisedTasks = parseTasksFromSpec(currentPlanContent);
46644697
logger.info(`Revised plan has ${revisedTasks.length} tasks`);
46654698

4699+
// Warn if no tasks found in spec/full mode - this may cause fallback to single-agent
4700+
if (
4701+
revisedTasks.length === 0 &&
4702+
(planningMode === 'spec' || planningMode === 'full')
4703+
) {
4704+
logger.warn(
4705+
`WARNING: Revised plan in ${planningMode} mode has no tasks! ` +
4706+
`This will cause fallback to single-agent execution. ` +
4707+
`The AI may have omitted the required \`\`\`tasks block.`
4708+
);
4709+
this.emitAutoModeEvent('plan_revision_warning', {
4710+
featureId,
4711+
projectPath,
4712+
branchName,
4713+
planningMode,
4714+
warning:
4715+
'Revised plan missing tasks block - will use single-agent execution',
4716+
});
4717+
}
4718+
46664719
// Update planSpec with revised content
46674720
await this.updateFeaturePlanSpec(projectPath, featureId, {
46684721
status: 'generated',

libs/prompts/src/defaults.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,20 @@ export const DEFAULT_PLAN_REVISION_TEMPLATE = `The user has requested revisions
965965
966966
## Instructions
967967
Please regenerate the specification incorporating the user's feedback.
968-
Keep the same format with the \`\`\`tasks block for task definitions.
969-
After generating the revised spec, output:
968+
**Current planning mode: {{planningMode}}**
969+
970+
**CRITICAL REQUIREMENT**: Your revised specification MUST include a \`\`\`tasks code block containing task definitions in the EXACT format shown below. This is MANDATORY - without the tasks block, the system cannot track or execute tasks properly.
971+
972+
### Required Task Format
973+
{{taskFormatExample}}
974+
975+
**IMPORTANT**:
976+
1. The \`\`\`tasks block must appear in your response
977+
2. Each task MUST start with "- [ ] T###:" where ### is a sequential number (T001, T002, T003, etc.)
978+
3. Each task MUST include "| File:" followed by the primary file path
979+
4. Tasks should be ordered by dependencies (foundational tasks first)
980+
981+
After generating the revised spec with the tasks block, output:
970982
"[SPEC_GENERATED] Please review the revised specification above."`;
971983

972984
export const DEFAULT_CONTINUATION_AFTER_APPROVAL_TEMPLATE = `The plan/specification has been approved. Now implement it.

0 commit comments

Comments
 (0)