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:
parent
7d64aac6bb
commit
d9548cdf26
1 changed files with 13 additions and 3 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue