Skip to content

feat(browser_toolset): enhance error handling and connection management#57

Open
Sodawyx wants to merge 1 commit intomainfrom
fix-browser-toolset-lifecycle
Open

feat(browser_toolset): enhance error handling and connection management#57
Sodawyx wants to merge 1 commit intomainfrom
fix-browser-toolset-lifecycle

Conversation

@Sodawyx
Copy link
Collaborator

@Sodawyx Sodawyx commented Mar 2, 2026

Fix bug #55

  • Introduced BrowserToolError for tool-level errors, ensuring they don't trigger sandbox recreation.
  • Implemented connection caching for Playwright in BrowserToolSet, optimizing resource usage.
  • Enhanced _run_in_sandbox method to differentiate between infrastructure and tool-level errors, improving error handling.
  • Added unit tests for error handling and connection management in BrowserToolSet.

This update improves the robustness of the browser toolset by refining error handling and optimizing Playwright connection management.

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Fix bug #55

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves BrowserToolSet robustness by preventing tool-level Playwright failures from triggering expensive sandbox recreation, and by reusing a cached Playwright connection to reduce transient CDP/connect overhead.

Changes:

  • Add Playwright connection caching in BrowserToolSet and reset it on sandbox rebuild/close.
  • Refine _run_in_sandbox to distinguish infrastructure errors vs tool-level errors for browser operations.
  • Add unit tests for the new error handling and caching behavior; plus minor formatting-only test/schema tweaks.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
agentrun/integration/builtin/sandbox.py Implements Playwright connection caching and browser-specific error classification/retry behavior.
agentrun/utils/exception.py Introduces BrowserToolError exception type for tool-level browser failures.
tests/unittests/integration/test_browser_toolset_error_handling.py Adds unit tests for infrastructure vs tool-level error handling and Playwright caching/reset behavior.
agentrun/integration/utils/tool.py Minor formatting adjustment in OpenAPI schema generation.
tests/unittests/toolset/api/test_openapi.py Formatting-only normalization of $ref strings in test fixtures.
tests/unittests/integration/test_langchain_agui_integration.py Formatting-only normalization of request JSON test payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Introduced BrowserToolError for tool-level errors, ensuring they don't trigger sandbox recreation.
- Implemented connection caching for Playwright in BrowserToolSet, optimizing resource usage.
- Enhanced _run_in_sandbox method to differentiate between infrastructure and tool-level errors, improving error handling.
- Added unit tests for error handling and connection management in BrowserToolSet.

This update improves the robustness of the browser toolset by refining error handling and optimizing Playwright connection management.

Signed-off-by: Sodawyx <sodawyx@126.com>
@Sodawyx Sodawyx force-pushed the fix-browser-toolset-lifecycle branch from 9c51ebe to 688b57b Compare March 2, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants