From d9548cdf269339899bce4890a1eba0c8c7e17d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=82CHES?= Date: Fri, 13 Mar 2026 10:39:00 -0600 Subject: [PATCH] fix: pause auto-mode on provider errors to prevent reassess-roadmap loop (#95) (#202) When a provider returns a fetch error, the agent_end hook now detects stopReason === "error" and pauses auto-mode. This prevents the state machine from silently re-dispatching the same phase until stuck detection fires. Co-authored-by: Claude Opus 4.6 --- src/resources/extensions/gsd/index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/resources/extensions/gsd/index.ts b/src/resources/extensions/gsd/index.ts index 8c0ec1791..6edc7a484 100644 --- a/src/resources/extensions/gsd/index.ts +++ b/src/resources/extensions/gsd/index.ts @@ -325,14 +325,24 @@ export default function (pi: ExtensionAPI) { // If auto-mode is already running, advance to next unit if (!isAutoActive()) return; - // If the agent was aborted (user pressed Escape), pause auto-mode - // instead of advancing. This preserves the conversation so the user - // can inspect what happened, interact with the agent, or resume. + // If the agent was aborted (user pressed Escape) or hit a provider + // error (fetch failure, rate limit, etc.), pause auto-mode instead of + // advancing. This preserves the conversation so the user can inspect + // what happened, interact with the agent, or resume. const lastMsg = event.messages[event.messages.length - 1]; if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "aborted") { await pauseAuto(ctx, pi); return; } + if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "error") { + const errorDetail = + "errorMessage" in lastMsg && lastMsg.errorMessage + ? `: ${lastMsg.errorMessage}` + : ""; + ctx.log(`Auto-mode paused due to provider error${errorDetail}`); + await pauseAuto(ctx, pi); + return; + } await handleAgentEnd(ctx, pi); });