From 8335aa0fa061d5fec84f87e23668f9c221a5a3dd Mon Sep 17 00:00:00 2001 From: Ari Webb Date: Mon, 2 Mar 2026 16:50:49 -0800 Subject: [PATCH] fix: add some more logging for interrupts (#9733) --- letta/server/rest_api/routers/v1/agents.py | 7 +++++++ letta/server/rest_api/routers/v1/conversations.py | 6 ++++++ letta/services/run_manager.py | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py index bf25f259..9f4a079e 100644 --- a/letta/server/rest_api/routers/v1/agents.py +++ b/letta/server/rest_api/routers/v1/agents.py @@ -1868,6 +1868,13 @@ async def cancel_message( """ # TODO: WHY DOES THIS CANCEL A LIST OF RUNS? actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id) + logger.info( + "[Interrupt] Cancel request received for agent=%s by actor=%s (org=%s), explicit_run_ids=%s", + agent_id, + actor.id, + actor.organization_id, + request.run_ids if request else None, + ) if not settings.track_agent_run: raise HTTPException(status_code=400, detail="Agent run tracking is disabled") run_ids = request.run_ids if request else None diff --git a/letta/server/rest_api/routers/v1/conversations.py b/letta/server/rest_api/routers/v1/conversations.py index a3258e7c..d7444d87 100644 --- a/letta/server/rest_api/routers/v1/conversations.py +++ b/letta/server/rest_api/routers/v1/conversations.py @@ -580,6 +580,12 @@ async def cancel_conversation( for the agent's default conversation. """ actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id) + logger.info( + "[Interrupt] Cancel request received for conversation=%s by actor=%s (org=%s)", + conversation_id, + actor.id, + actor.organization_id, + ) if not settings.track_agent_run: raise HTTPException(status_code=400, detail="Agent run tracking is disabled") diff --git a/letta/services/run_manager.py b/letta/services/run_manager.py index 7283b701..7edc9d3a 100644 --- a/letta/services/run_manager.py +++ b/letta/services/run_manager.py @@ -638,7 +638,13 @@ class RunManager: raise NoResultFound(f"Run with id {run_id} not found") agent_id = run.agent_id - logger.debug(f"Cancelling run {run_id} for agent {agent_id}") + logger.info( + "[Interrupt] Processing cancellation for run=%s, agent=%s, current_status=%s, current_stop_reason=%s", + run_id, + agent_id, + run.status if run else "unknown", + run.stop_reason if run else "unknown", + ) # Cancellation should be idempotent: if a run is already terminated, treat this as a no-op. # This commonly happens when a run finishes between client request and server handling.