@@ -424,6 +424,8 @@ def __init__(
424
424
self .cloud_sync = cloud_sync or CloudSync ()
425
425
# Register cloud sync handler
426
426
self .eventbus .on ('*' , self .cloud_sync .handle_event )
427
+ else :
428
+ self .cloud_sync = None
427
429
428
430
if self .settings .save_conversation_path :
429
431
self .settings .save_conversation_path = Path (self .settings .save_conversation_path ).expanduser ().resolve ()
@@ -835,15 +837,16 @@ async def _finalize(self, browser_state_summary: BrowserStateSummary | None) ->
835
837
action_dict = action .model_dump () if hasattr (action , 'model_dump' ) else {}
836
838
actions_data .append (action_dict )
837
839
838
- # Emit CreateAgentStepEvent
839
- step_event = CreateAgentStepEvent .from_agent_step (
840
- self ,
841
- self .state .last_model_output ,
842
- self .state .last_result ,
843
- actions_data ,
844
- browser_state_summary ,
845
- )
846
- self .eventbus .dispatch (step_event )
840
+ # Emit CreateAgentStepEvent only if cloud sync is enabled
841
+ if self .enable_cloud_sync :
842
+ step_event = CreateAgentStepEvent .from_agent_step (
843
+ self ,
844
+ self .state .last_model_output ,
845
+ self .state .last_result ,
846
+ actions_data ,
847
+ browser_state_summary ,
848
+ )
849
+ self .eventbus .dispatch (step_event )
847
850
848
851
# Increment step counter after step is fully completed
849
852
self .state .n_steps += 1
@@ -1415,18 +1418,20 @@ def on_force_exit_log_telemetry():
1415
1418
1416
1419
# Only dispatch session events if this is the first run
1417
1420
if not self .state .session_initialized :
1418
- self .logger .debug ('📡 Dispatching CreateAgentSessionEvent...' )
1419
- # Emit CreateAgentSessionEvent at the START of run()
1420
- self .eventbus .dispatch (CreateAgentSessionEvent .from_agent (self ))
1421
+ if self .enable_cloud_sync :
1422
+ self .logger .debug ('📡 Dispatching CreateAgentSessionEvent...' )
1423
+ # Emit CreateAgentSessionEvent at the START of run()
1424
+ self .eventbus .dispatch (CreateAgentSessionEvent .from_agent (self ))
1421
1425
1422
- self .state .session_initialized = True
1426
+ # Brief delay to ensure session is created in backend before sending task
1427
+ await asyncio .sleep (0.2 )
1423
1428
1424
- # Brief delay to ensure session is created in backend before sending task
1425
- await asyncio .sleep (0.2 )
1429
+ self .state .session_initialized = True
1426
1430
1427
- self .logger .debug ('📡 Dispatching CreateAgentTaskEvent...' )
1428
- # Emit CreateAgentTaskEvent at the START of run()
1429
- self .eventbus .dispatch (CreateAgentTaskEvent .from_agent (self ))
1431
+ if self .enable_cloud_sync :
1432
+ self .logger .debug ('📡 Dispatching CreateAgentTaskEvent...' )
1433
+ # Emit CreateAgentTaskEvent at the START of run()
1434
+ self .eventbus .dispatch (CreateAgentTaskEvent .from_agent (self ))
1430
1435
1431
1436
# Start browser session and attach watchdogs
1432
1437
assert self .browser_session is not None , 'Browser session must be initialized before starting'
@@ -1572,7 +1577,8 @@ def on_force_exit_log_telemetry():
1572
1577
# not when they are completed
1573
1578
1574
1579
# Emit UpdateAgentTaskEvent at the END of run() with final task state
1575
- self .eventbus .dispatch (UpdateAgentTaskEvent .from_agent (self ))
1580
+ if self .enable_cloud_sync :
1581
+ self .eventbus .dispatch (UpdateAgentTaskEvent .from_agent (self ))
1576
1582
1577
1583
# Generate GIF if needed before stopping event bus
1578
1584
if self .settings .generate_gif :
@@ -1591,7 +1597,7 @@ def on_force_exit_log_telemetry():
1591
1597
self .eventbus .dispatch (output_event )
1592
1598
1593
1599
# Wait briefly for cloud auth to start and print the URL, but don't block for completion
1594
- if self .enable_cloud_sync and hasattr (self , 'cloud_sync' ):
1600
+ if self .enable_cloud_sync and hasattr (self , 'cloud_sync' ) and self . cloud_sync is not None :
1595
1601
if self .cloud_sync .auth_task and not self .cloud_sync .auth_task .done ():
1596
1602
try :
1597
1603
# Wait up to 1 second for auth to start and print URL
0 commit comments