Ver Fonte

SocketIO init event ordering (#5714)

Co-authored-by: tofarr <tofarr@gmail.com>
diwu-sf há 1 ano atrás
pai
commit
5e8c20f406
1 ficheiros alterados com 5 adições e 3 exclusões
  1. 5 3
      openhands/server/listen_socket.py

+ 5 - 3
openhands/server/listen_socket.py

@@ -4,6 +4,7 @@ from github import Github
 from socketio.exceptions import ConnectionRefusedError
 
 from openhands.core.logger import openhands_logger as logger
+from openhands.core.schema.agent import AgentState
 from openhands.events.action import (
     NullAction,
 )
@@ -79,10 +80,11 @@ async def connect(connection_id: str, environ, auth):
         ):
             continue
         elif isinstance(event, AgentStateChangedObservation):
+            if event.agent_state == AgentState.INIT:
+                await sio.emit('oh_event', event_to_dict(event), to=connection_id)
             agent_state_changed = event
-            continue
-        await sio.emit('oh_event', event_to_dict(event), to=connection_id)
-
+        else:
+            await sio.emit('oh_event', event_to_dict(event), to=connection_id)
     if agent_state_changed:
         await sio.emit('oh_event', event_to_dict(agent_state_changed), to=connection_id)