accept Socket.IO disconnect reason
Update the WebSocket disconnect handler signature to accept the disconnect reason now passed by python-socketio. Agent Zero does not currently use the reason value, but keeping the parameter matches the documented Socket.IO callback shape and avoids relying on the library's legacy one-argument handler fallback. python-socketio>=5.14.2 now documents server disconnect handlers as receiving sid, reason: https://python-socketio.readthedocs.io/en/stable/server.html#connect-and-disconnect-events. The 5.14.2 source also passes that reason into the disconnect event. It still has a legacy fallback that retries old one-arg handlers, so removing it would probably work today, but only by leaning on compatibility behavior.
Alessandro committed
Apr 24, 2026 at 14:14 UTC
76130ae5ac086b9ba3c0a80f70070f8df7be8507
1 file changed
+1
-1
helpers/ws.py
+1
-1
@@ -535,7 +535,7 @@ def register_ws_namespace(
535
return True
536
537
@socketio_server.on("disconnect", namespace=NAMESPACE) # type: ignore
538
- async def _on_disconnect(sid):
538
+ async def _on_disconnect(sid, reason=None):
539
with _contexts_lock:
540
activated = _active_handlers.pop(sid, {})
541
_ws_contexts.pop(sid, None)