Skip to content

Commit 5cc9ce1

Browse files
committed
fix(browser): change default wait_until from load to domcontentloaded
Updated the default wait_until parameter from 'load' to 'domcontentloaded' for browser navigation functions to improve performance and reduce waiting time for full page loads when not necessary. This change affects browser_navigate_back and browser_go_forward functions in the BrowserToolSet class to use 'domcontentloaded' as the default waiting strategy instead of 'load'. 将默认的 wait_until 参数从 'load' 更改为 'domcontentloaded' 更新了浏览器导航函数的默认 wait_until 参数,从 'load' 改为 'domcontentloaded' 以提高性能并减少不必要的完整页面加载等待时间。 此更改影响 BrowserToolSet 类中的 browser_navigate_back 和 browser_go_forward 函数,使用 'domcontentloaded' 作为默认等待策略 而不是 'load'。 fix #66 Change-Id: Ib5d4120869bfea9ea8a411b16958bf9359572b9f Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent 5dd5e41 commit 5cc9ce1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

agentrun/integration/builtin/sandbox.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,20 +751,26 @@ def _get_playwright(self, sb: BrowserSandbox) -> "BrowserPlaywrightSync":
751751
Automatically recreates the connection when the thread that created it has exited,
752752
because Playwright's internal greenlet is bound to the thread that created it.
753753
"""
754-
if self._playwright_sync is not None and self._playwright_thread is not None:
754+
if (
755+
self._playwright_sync is not None
756+
and self._playwright_thread is not None
757+
):
755758
current_thread = threading.current_thread()
756759
creator_thread = self._playwright_thread
757-
if not creator_thread.is_alive() or current_thread is not creator_thread:
760+
if (
761+
not creator_thread.is_alive()
762+
or current_thread is not creator_thread
763+
):
758764
if not creator_thread.is_alive():
759765
logger.debug(
760-
"Playwright creating thread (id=%s) has exited, recreating"
761-
" connection",
766+
"Playwright creating thread (id=%s) has exited,"
767+
" recreating connection",
762768
creator_thread.ident,
763769
)
764770
else:
765771
logger.debug(
766-
"Playwright creating thread (id=%s) differs from current"
767-
" thread (id=%s), recreating connection",
772+
"Playwright creating thread (id=%s) differs from"
773+
" current thread (id=%s), recreating connection",
768774
creator_thread.ident,
769775
current_thread.ident,
770776
)
@@ -970,7 +976,7 @@ def goto(self, url: str) -> Dict[str, Any]:
970976
)
971977
def browser_navigate_back(
972978
self,
973-
wait_until: str = "load",
979+
wait_until: str = "domcontentloaded",
974980
timeout: Optional[float] = None,
975981
) -> Dict[str, Any]:
976982
"""返回上一页 / Go back to previous page"""
@@ -996,7 +1002,7 @@ def inner(sb: Sandbox):
9961002
)
9971003
def browser_go_forward(
9981004
self,
999-
wait_until: str = "load",
1005+
wait_until: str = "domcontentloaded",
10001006
timeout: Optional[float] = None,
10011007
) -> Dict[str, Any]:
10021008
"""前进到下一页 / Go forward to next page"""

0 commit comments

Comments
 (0)