Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: add some more logging for interrupts (#9733)
Ari Webb8335aa0fa061
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex bf25f259e..9f4a079e9 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 Nonediff --git a/letta/server/rest_api/routers/v1/conversations.py b/letta/server/rest_api/routers/v1/conversations.pyindex a3258e7cf..d7444d871 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.pyindex 7283b701d..7edc9d3a0 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.