From 32ee7e6cf8b4df5312e744c5da32eaa3abc56a2c Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Fri, 6 Feb 2026 11:45:54 +0400 Subject: [PATCH] fix(chat): Remove aggressive stale task detection The 60-second timeout was too aggressive and could incorrectly mark legitimate long-running tool calls as stale. Relying on Redis TTL (1 hour) for cleanup is sufficient and more reliable. --- .../api/features/chat/stream_registry.py | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/stream_registry.py b/autogpt_platform/backend/backend/api/features/chat/stream_registry.py index 35b7681482..5af9df706c 100644 --- a/autogpt_platform/backend/backend/api/features/chat/stream_registry.py +++ b/autogpt_platform/backend/backend/api/features/chat/stream_registry.py @@ -555,27 +555,6 @@ async def get_active_task_for_session( if task_user_id and user_id != task_user_id: continue - # Skip stale tasks (running for more than 5 minutes is suspicious) - created_at_str = meta.get("created_at", "") - if created_at_str: - try: - created_at = datetime.fromisoformat(created_at_str) - age_seconds = ( - datetime.now(timezone.utc) - created_at - ).total_seconds() - if ( - age_seconds > 60 - ): # 1 minute - tasks orphaned by server restart - logger.warning( - f"[TASK_LOOKUP] Skipping stale task {task_id[:8]}... " - f"(age={age_seconds:.0f}s)" - ) - # Mark stale task as failed to clean it up - await mark_task_completed(task_id, "failed") - continue - except (ValueError, TypeError): - pass # If we can't parse the date, continue with the task - logger.info( f"[TASK_LOOKUP] Found running task {task_id[:8]}... for session {session_id[:8]}..." )