@@ -131,7 +131,7 @@ async def run_browser_agent(
131
131
if new_videos - existing_videos :
132
132
latest_video = list (new_videos - existing_videos )[0 ] # Get the first new video
133
133
134
- return final_result , errors , model_actions , model_thoughts , latest_video
134
+ return final_result , errors , model_actions , model_thoughts , latest_video , trace_file
135
135
136
136
async def run_org_agent (
137
137
llm ,
@@ -292,7 +292,7 @@ async def run_custom_agent(
292
292
recorded_files = get_latest_files (save_recording_path )
293
293
trace_file = get_latest_files (save_trace_path )
294
294
295
- return final_result , errors , model_actions , model_thoughts , trace_file .get ('.webm' ), recorded_files .get ('.zip' )
295
+ return final_result , errors , model_actions , model_thoughts , recorded_files .get ('.webm' ), trace_file .get ('.zip' )
296
296
except Exception as e :
297
297
import traceback
298
298
traceback .print_exc ()
@@ -389,22 +389,22 @@ async def run_with_stream(
389
389
# Initialize values for streaming
390
390
html_content = "<div style='width:80vw; height:90vh'>Using browser...</div>"
391
391
final_result = errors = model_actions = model_thoughts = ""
392
- recording = trace = None
392
+ latest_videos = trace = None
393
393
394
394
# Periodically update the stream while the agent task is running
395
395
while not agent_task .done ():
396
396
try :
397
397
html_content = await capture_screenshot (_global_browser_context )
398
398
except Exception as e :
399
- html_content = f"<div class='error' style='width:80vw; height:90vh'>Screenshot error: { str ( e ) } </div>"
399
+ html_content = f"<div style='width:80vw; height:90vh'>Waiting for browser session... </div>"
400
400
401
401
yield [
402
402
html_content ,
403
403
final_result ,
404
404
errors ,
405
405
model_actions ,
406
406
model_thoughts ,
407
- recording ,
407
+ latest_videos ,
408
408
trace ,
409
409
]
410
410
await asyncio .sleep (0.01 )
@@ -413,7 +413,7 @@ async def run_with_stream(
413
413
try :
414
414
result = await agent_task
415
415
if isinstance (result , tuple ) and len (result ) == 6 :
416
- final_result , errors , model_actions , model_thoughts , recording , trace = agent_task
416
+ final_result , errors , model_actions , model_thoughts , latest_videos , trace = result
417
417
else :
418
418
errors = "Unexpected result format from agent"
419
419
except Exception as e :
@@ -425,14 +425,14 @@ async def run_with_stream(
425
425
errors ,
426
426
model_actions ,
427
427
model_thoughts ,
428
- recording ,
428
+ latest_videos ,
429
429
trace ,
430
430
]
431
431
432
432
except Exception as e :
433
433
import traceback
434
434
yield [
435
- f"<div class='error' style='width:80vw; height:90vh'>Browser error: { str ( e ) } </div>" ,
435
+ f"<div style='width:80vw; height:90vh'>Waiting for browser session... </div>" ,
436
436
"" ,
437
437
f"Error: { str (e )} \n { traceback .format_exc ()} " ,
438
438
"" ,
@@ -745,13 +745,13 @@ def list_recordings(save_recording_path):
745
745
enable_recording , task , add_infos , max_steps , use_vision , max_actions_per_step , tool_call_in_content
746
746
],
747
747
outputs = [
748
- browser_view ,
749
- final_result_output ,
750
- errors_output ,
751
- model_actions_output ,
752
- model_thoughts_output ,
753
- recording_display ,
754
- trace_file
748
+ browser_view , # HTML view
749
+ final_result_output , # Final result
750
+ errors_output , # Errors
751
+ model_actions_output , # Model actions
752
+ model_thoughts_output , # Model thoughts
753
+ recording_display , # Video file (.webm)
754
+ trace_file # Trace file (.zip)
755
755
],
756
756
queue = True ,
757
757
)
0 commit comments