Skip to content

Commit 915e97a

Browse files
OhYeeCopilot
andauthored
Update agentrun/integration/builtin/sandbox.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent d1bafaf commit 915e97a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

agentrun/integration/builtin/sandbox.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,21 @@ def _run_in_sandbox(self, callback: Callable[[Sandbox], Any]) -> Any:
843843
"Greenlet thread-binding error, resetting Playwright: %s",
844844
e,
845845
)
846-
self._reset_playwright()
847-
self.sandbox = None
846+
# Reset only the Playwright connection and keep the existing sandbox
847+
try:
848+
self._reset_playwright()
849+
# Retry once with the same sandbox instance; the original error
850+
# will still be returned if this retry fails.
851+
return callback(sb)
852+
except Exception as e2:
853+
logger.debug(
854+
"Retry after Playwright reset failed: %s",
855+
e2,
856+
)
857+
return {"error": f"{e!s}"}
848858
else:
849859
logger.debug("Unexpected error in browser sandbox: %s", e)
850-
return {"error": f"{e!s}"}
860+
return {"error": f"{e!s}"}
851861

852862
def _is_infrastructure_error(self, error_msg: str) -> bool:
853863
"""判断是否为基础设施错误 / Check if error is infrastructure-level

0 commit comments

Comments
 (0)