diff --git a/src/agents/command/attempt-execution.helpers.ts b/src/agents/command/attempt-execution.helpers.ts index f9abc3401c1..2315346ecf5 100644 --- a/src/agents/command/attempt-execution.helpers.ts +++ b/src/agents/command/attempt-execution.helpers.ts @@ -73,7 +73,13 @@ export function resolveFallbackRetryPrompt(params: { if (!params.sessionHasHistory) { return params.body; } - return "Continue where you left off. The previous model attempt failed or timed out."; + // Even with persisted session history, fully replacing the body with a + // generic "continue where you left off" message strips the original task + // from the fallback model's view. Agents then have to reconstruct the + // instruction from history alone, which is fragile and sometimes + // impossible. Prepend the retry context to the original body instead so + // the fallback model has both the recovery signal AND the task. (#65760) + return `[Retry after the previous model attempt failed or timed out]\n\n${params.body}`; } export function createAcpVisibleTextAccumulator() { diff --git a/src/agents/command/attempt-execution.test.ts b/src/agents/command/attempt-execution.test.ts index b1b5ab72700..6ab929778bd 100644 --- a/src/agents/command/attempt-execution.test.ts +++ b/src/agents/command/attempt-execution.test.ts @@ -20,14 +20,14 @@ describe("resolveFallbackRetryPrompt", () => { ).toBe(originalBody); }); - it("returns recovery prompt for fallback retry with existing session history", () => { + it("prepends recovery prefix to original body on fallback retry with existing session history", () => { expect( resolveFallbackRetryPrompt({ body: originalBody, isFallbackRetry: true, sessionHasHistory: true, }), - ).toBe("Continue where you left off. The previous model attempt failed or timed out."); + ).toBe(`[Retry after the previous model attempt failed or timed out]\n\n${originalBody}`); }); it("preserves original body for fallback retry when session has no history (subagent spawn)", () => {