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 <noreply@anthropic.com>
This commit is contained in:
TÂCHES 2026-03-13 10:39:00 -06:00 committed by GitHub
parent 7d64aac6bb
commit d9548cdf26

View file

@ -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);
});