Compare commits

...

3 Commits

Author SHA1 Message Date
Aishanee Shah c5a8156b5e Merge branch 'main' into fix/non-interactive-error-recovery 2026-03-16 18:19:05 -04:00
Aishanee Shah 96402892ee Merge branch 'main' into fix/non-interactive-error-recovery 2026-03-16 18:05:40 -04:00
Bryan Morgan b949049dcb feat(core): add error recovery guidance to non-interactive system prompt
The autonomous system prompt did not guide the agent on error recovery,
causing fallback loops. Adds a non-interactive error recovery section
to renderOperationalGuidelines() gated behind !options.interactive.

Covers: analyze before retrying, two-strike rule for trying alternatives,
avoid alternating-approach loops, verify fixes incrementally.
2026-03-12 15:16:50 -04:00
2 changed files with 24 additions and 2 deletions
@@ -923,7 +923,13 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi
## Interaction Details
- **Help Command:** The user can use '/help' to display help information.
- **Feedback:** To report a bug or provide feedback, please use the /bug command."
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
## Error Recovery (Non-Interactive)
- **Analyze before retrying:** When a command or tool call fails, read the error message carefully. Identify the root cause before attempting a fix. Do not blindly retry the same command.
- **Two-strike rule:** If the same approach fails twice, try a fundamentally different approach. Do not repeat a failing strategy more than twice.
- **Avoid loops:** If you find yourself alternating between two approaches that both fail, stop and reassess. Consider whether the task requirements need to be adjusted or a completely different tool/method is needed.
- **Incremental progress:** After recovering from an error, verify the fix worked before moving on. Do not assume success."
`;
exports[`Core System Prompt (prompts.ts) > should handle CodebaseInvestigator with tools=grep_search,glob 1`] = `
@@ -1046,7 +1052,13 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi
## Interaction Details
- **Help Command:** The user can use '/help' to display help information.
- **Feedback:** To report a bug or provide feedback, please use the /bug command."
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
## Error Recovery (Non-Interactive)
- **Analyze before retrying:** When a command or tool call fails, read the error message carefully. Identify the root cause before attempting a fix. Do not blindly retry the same command.
- **Two-strike rule:** If the same approach fails twice, try a fundamentally different approach. Do not repeat a failing strategy more than twice.
- **Avoid loops:** If you find yourself alternating between two approaches that both fail, stop and reassess. Consider whether the task requirements need to be adjusted or a completely different tool/method is needed.
- **Incremental progress:** After recovering from an error, verify the fix worked before moving on. Do not assume success."
`;
exports[`Core System Prompt (prompts.ts) > should handle git instructions when isGitRepository=false 1`] = `
+10
View File
@@ -379,9 +379,19 @@ export function renderOperationalGuidelines(
## Interaction Details
- **Help Command:** The user can use '/help' to display help information.
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
${!options.interactive ? nonInteractiveErrorRecovery() : ''}
`.trim();
}
function nonInteractiveErrorRecovery(): string {
return `
## Error Recovery (Non-Interactive)
- **Analyze before retrying:** When a command or tool call fails, read the error message carefully. Identify the root cause before attempting a fix. Do not blindly retry the same command.
- **Two-strike rule:** If the same approach fails twice, try a fundamentally different approach. Do not repeat a failing strategy more than twice.
- **Avoid loops:** If you find yourself alternating between two approaches that both fail, stop and reassess. Consider whether the task requirements need to be adjusted or a completely different tool/method is needed.
- **Incremental progress:** After recovering from an error, verify the fix worked before moving on. Do not assume success.`;
}
export function renderSandbox(mode?: SandboxMode): string {
if (!mode) return '';
if (mode === 'macos-seatbelt') {