From cd4e2023ab7279e2c1a618a94b963de0343cd7e1 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 6 Jan 2026 19:34:54 -0300 Subject: [PATCH] fix(agent): capture compaction retry AbortError for model fallback Wrap waitForCompactionRetry() in try/catch to capture AbortError that was escaping and bypassing the model fallback mechanism. When a timeout fires, session.abort() causes both session.prompt() and waitForCompactionRetry() to throw AbortError. Previously only the prompt error was captured, allowing the compaction error to escape to model-fallback.ts where it was immediately re-thrown (line 199: isAbortError check), bypassing fallback model attempts. Fixes #313 --- src/agents/pi-embedded-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-runner.ts b/src/agents/pi-embedded-runner.ts index c4113c774..91e3105e1 100644 --- a/src/agents/pi-embedded-runner.ts +++ b/src/agents/pi-embedded-runner.ts @@ -923,7 +923,7 @@ export async function runEmbeddedPiAgent(params: { try { await waitForCompactionRetry(); } catch (err) { - // Capture AbortError from waitForCompactionRetry to enable fallback/rotation + // Capture AbortError from waitForCompactionRetry to enable fallback/rotation. if (isAbortError(err)) { if (!promptError) promptError = err; } else {