Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix: mark stale turns cancelled before reporting no active turn (P2-11)

unknownf83e950dd813
diff --git a/deeptutor/api/routers/unified_ws.py b/deeptutor/api/routers/unified_ws.py
index 9ceb30b60..e9184835f 100644
--- a/deeptutor/api/routers/unified_ws.py
+++ b/deeptutor/api/routers/unified_ws.py
@@ -181,6 +181,9 @@ async def unified_websocket(ws: WebSocket) -> None:
"status": active_turn.get("status", "running"),
})
else:
+ # Stale turn from a previous process — mark it terminal
+ # so create_turn won't reject the upcoming start_turn.
+ await runtime.store.update_turn_status(turn_id, "cancelled", "Stale turn after restart")
await safe_send({"type": "active_turn_info", "turn_id": "", "status": "none"})
else:
await safe_send({"type": "active_turn_info", "turn_id": "", "status": "none"})