File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ async def run_custom_agent(
199
199
controller = CustomController ()
200
200
playwright = None
201
201
browser_context_ = None
202
+ browser = None # Initialize browser to None
202
203
try :
203
204
if use_own_browser :
204
205
playwright = await async_playwright ().start ()
@@ -278,14 +279,18 @@ async def run_custom_agent(
278
279
model_actions = ""
279
280
model_thoughts = ""
280
281
finally :
281
- # 显式关闭持久化上下文
282
+ # Close persistent context if it was initialized
282
283
if browser_context_ :
283
284
await browser_context_ .close ()
284
285
285
- # 关闭 Playwright 对象
286
+ # Stop Playwright if it was started
286
287
if playwright :
287
288
await playwright .stop ()
288
- await browser .close ()
289
+
290
+ # Close the browser if it was initialized
291
+ if browser :
292
+ await browser .close ()
293
+
289
294
return final_result , errors , model_actions , model_thoughts
290
295
291
296
# Define the theme map globally
You can’t perform that action at this time.
0 commit comments