@@ -131,7 +131,7 @@ async def run_browser_agent(
131
131
api_key = llm_api_key ,
132
132
)
133
133
if agent_type == "org" :
134
- final_result , errors , model_actions , model_thoughts , trace_file = await run_org_agent (
134
+ final_result , errors , model_actions , model_thoughts , trace_file , history_file = await run_org_agent (
135
135
llm = llm ,
136
136
use_own_browser = use_own_browser ,
137
137
keep_browser_open = keep_browser_open ,
@@ -140,6 +140,7 @@ async def run_browser_agent(
140
140
window_w = window_w ,
141
141
window_h = window_h ,
142
142
save_recording_path = save_recording_path ,
143
+ save_agent_history_path = save_agent_history_path ,
143
144
save_trace_path = save_trace_path ,
144
145
task = task ,
145
146
max_steps = max_steps ,
@@ -201,8 +202,8 @@ async def run_browser_agent(
201
202
'' , # model_actions
202
203
'' , # model_thoughts
203
204
None , # latest_video
204
- None , # trace_file
205
205
None , # history_file
206
+ None , # trace_file
206
207
gr .update (value = "Stop" , interactive = True ), # Re-enable stop button
207
208
gr .update (value = "Run" , interactive = True ) # Re-enable run button
208
209
)
@@ -217,6 +218,7 @@ async def run_org_agent(
217
218
window_w ,
218
219
window_h ,
219
220
save_recording_path ,
221
+ save_agent_history_path ,
220
222
save_trace_path ,
221
223
task ,
222
224
max_steps ,
@@ -270,14 +272,17 @@ async def run_org_agent(
270
272
)
271
273
history = await agent .run (max_steps = max_steps )
272
274
275
+ history_file = os .path .join (save_agent_history_path , f"{ agent .agent_id } .json" )
276
+ agent .save_history (history_file )
277
+
273
278
final_result = history .final_result ()
274
279
errors = history .errors ()
275
280
model_actions = history .model_actions ()
276
281
model_thoughts = history .model_thoughts ()
277
-
282
+
278
283
trace_file = get_latest_files (save_trace_path )
279
-
280
- return final_result , errors , model_actions , model_thoughts , trace_file .get ('.zip' )
284
+
285
+ return final_result , errors , model_actions , model_thoughts , trace_file .get ('.zip' ), history_file
281
286
except Exception as e :
282
287
import traceback
283
288
traceback .print_exc ()
@@ -381,7 +386,7 @@ async def run_custom_agent(
381
386
import traceback
382
387
traceback .print_exc ()
383
388
errors = str (e ) + "\n " + traceback .format_exc ()
384
- return '' , errors , '' , '' , None
389
+ return '' , errors , '' , '' , None , None
385
390
finally :
386
391
# Handle cleanup based on persistence configuration
387
392
if not keep_browser_open :
0 commit comments