From 576485b0c915ea733eef56c5d57bb8ec8fa24539 Mon Sep 17 00:00:00 2001 From: Lauren Rosenberg Date: Sun, 18 Jan 2026 18:16:20 +0000 Subject: [PATCH] fix: return user-facing error when session reset after compaction failure Previously, when auto-compaction failed due to context overflow, the system would reset the session and silently continue the execution loop without sending any response to the user. This made it appear as if messages were being ignored. This change ensures users receive a clear error message explaining that the context limit was exceeded and the conversation has been reset, consistent with how role ordering conflicts are already handled. Fixes the silent failure case where message + compaction exceeds context limits. --- src/auto-reply/reply/agent-runner-execution.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/auto-reply/reply/agent-runner-execution.ts b/src/auto-reply/reply/agent-runner-execution.ts index 7fca6d4cf..3c2163723 100644 --- a/src/auto-reply/reply/agent-runner-execution.ts +++ b/src/auto-reply/reply/agent-runner-execution.ts @@ -397,7 +397,12 @@ export async function runAgentTurnWithFallback(params: { (await params.resetSessionAfterCompactionFailure(embeddedError.message)) ) { didResetAfterCompactionFailure = true; - continue; + return { + kind: "final", + payload: { + text: "⚠️ Context limit exceeded. I've reset our conversation to start fresh - please try again.", + }, + }; } if (embeddedError?.kind === "role_ordering") { const didReset = await params.resetSessionAfterRoleOrderingConflict(embeddedError.message); @@ -427,7 +432,12 @@ export async function runAgentTurnWithFallback(params: { (await params.resetSessionAfterCompactionFailure(message)) ) { didResetAfterCompactionFailure = true; - continue; + return { + kind: "final", + payload: { + text: "⚠️ Context limit exceeded during compaction. I've reset our conversation to start fresh - please try again.", + }, + }; } if (isRoleOrderingError) { const didReset = await params.resetSessionAfterRoleOrderingConflict(message);