Skip to content

Self-improving AI Employees for everyone

fix: Temporal heartbeat timeout for long-running activities

trohitg9d2304a2005e
diff --git a/server/routers/websocket.py b/server/routers/websocket.py
index a7584d49..ee44e9e4 100644
--- a/server/routers/websocket.py
+++ b/server/routers/websocket.py
@@ -42,13 +42,16 @@ _handler_tasks: weakref.WeakKeyDictionary = weakref.WeakKeyDictionary()
async def _safe_send(websocket: WebSocket, data: dict):
"""Thread-safe WebSocket send with lock to prevent concurrent writes."""
+ # Guard against sending on closed/disconnected WebSocket
+ if websocket.client_state.name != "CONNECTED":
+ return
if websocket not in _send_locks:
_send_locks[websocket] = asyncio.Lock()
async with _send_locks[websocket]:
try:
await websocket.send_json(data)
except Exception as e:
- logger.error(f"[WebSocket] Send error: {e}")
+ logger.debug("[WebSocket] Send skipped (connection closed): %s", e)
# Type for message handlers
diff --git a/server/services/temporal/activities.py b/server/services/temporal/activities.py
index 3b5a783b..85602ab0 100644
--- a/server/services/temporal/activities.py
+++ b/server/services/temporal/activities.py
@@ -204,18 +204,21 @@ class NodeExecutionActivities:
# Each activity gets its own WebSocket connection from the pool
async with self.session.ws_connect(
self.ws_url,
- heartbeat=20,
- receive_timeout=120,
+ heartbeat=30,
+ receive_timeout=540,
) as ws:
await ws.send_json(message)
# Wait for response with matching request_id
+ # Heartbeat on every non-matching message to stay alive during
+ # long-running operations (DeepAgent, browser, AI multi-tool loops)
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
response = json.loads(msg.data)
if response.get("request_id") == request_id:
activity.logger.debug(f"Got response for {node_id}: success={response.get('success')}")
return response
+ activity.heartbeat(f"Waiting for {node_id}")
elif msg.type == aiohttp.WSMsgType.ERROR:
raise Exception(f"WebSocket error: {ws.exception()}")
elif msg.type == aiohttp.WSMsgType.CLOSED:
diff --git a/server/skills/task_agent/write-todos-skill/SKILL.md b/server/skills/task_agent/write-todos-skill/SKILL.md
index da3c3aef..936bbe27 100644
--- a/server/skills/task_agent/write-todos-skill/SKILL.md
+++ b/server/skills/task_agent/write-todos-skill/SKILL.md
@@ -6,7 +6,7 @@ metadata:
author: machina
version: "2.0"
category: automation
- icon: "\uD83D\uDCDD"
+ icon: "📝"
color: "#bd93f9"
---