From cbfb8ea9b662212a854ebc81a4e2fd37bc9c0b54 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Wed, 19 Aug 2026 16:39:32 -0700 Subject: [PATCH] [eric] agents: the error path dispatches an armed self-heal continuation; the recap-free policy retry armed and then rotted because only the success path had a dispatcher (exp.19 drill catch) --- backend/apps/agents/agent_manager.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/apps/agents/agent_manager.py b/backend/apps/agents/agent_manager.py index cd6f5e91..bc31944e 100644 --- a/backend/apps/agents/agent_manager.py +++ b/backend/apps/agents/agent_manager.py @@ -295,6 +295,19 @@ class AgentManager(SessionLifecycle, SessionPersistence, Messaging, SessionContr ) return await handle_run_error(e, session, session_id, turn, p_stderr_buffer) + # An error handler may arm a self-heal continuation (the policy-block recap-free retry); + # the success path's dispatcher never runs on this branch, so dispatch it here or the + # armed retry silently rots and the session dies at "error" (caught by the exp.19 drill). + try: + if getattr(session, "pending_continuation", False): + p_cont = session.pending_continuation_prompt or "Continue." + session.pending_continuation = False + session.pending_continuation_prompt = None + session.status = "completed" + asyncio.create_task(self.send_message(session_id, p_cont, hidden=True)) + logger.info(f"Auto-continuing session {session_id} after a self-healing error path") + except Exception: + logger.exception("error-path continuation dispatch failed") except BaseException as e: # Catch BaseExceptionGroup from anyio task groups (e.g. concurrent CLI crash + pending approval cancellation) so it doesn't escape and kill the uvicorn process. logger.exception(f"Agent {session_id} fatal error: {e}")