Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| x, | ||
| y, | ||
| scroll_x, | ||
| scroll_y, |
There was a problem hiding this comment.
Drag action skips new structured validation error pattern
Medium Severity
The drag action (and default unknown-action case) still uses the old pattern of returning { success: false, error: "..." } instead of throwing ActionValidationError like all other refactored actions (click, type, scroll, goto, wait, keypress). This means drag validation errors are returned with HTTP 200 and no structured code/retryable/details fields, bypassing the new buildErrorResponse error classification in the server's catch block. The Python client won't format these errors with the new repairable feedback, and the model won't receive the same structured validation details it gets for other actions.
Additional Locations (1)
| CUA_SYSTEM_PROMPT_TEMPLATE = """You are a browser automation agent. You can control a web browser using the provided tools. | ||
|
|
||
| The display resolution is {viewport_width}x{viewport_height} pixels. | ||
| Use integer pixel coordinates measured from the top-left corner of the page. |
There was a problem hiding this comment.
Example prompt duplicates and diverges from default CUA prompt
Low Severity
CUA_SYSTEM_PROMPT_TEMPLATE in the example and _build_default_cua_system_prompt in browser_env.py both build viewport-aware CUA system prompts with overlapping but divergent content. The example's version hardcodes a tool list while the default version omits it; both inject {viewport_width}x{viewport_height}. Updating one without the other will silently introduce inconsistencies for users who switch between the example and direct BrowserEnv usage.
Additional Locations (1)
| CUA_SYSTEM_PROMPT = """You are a browser automation agent. You can control a web browser using the provided tools. | ||
| CUA_SYSTEM_PROMPT_TEMPLATE = """You are a browser automation agent. You can control a web browser using the provided tools. | ||
|
|
||
| The display resolution is {viewport_width}x{viewport_height} pixels. |
There was a problem hiding this comment.
this stuff should be in the tool definition not system prompt
| self.backoff_factor = backoff_factor | ||
| self.max_backoff_seconds = max_backoff_seconds | ||
| self.jitter = jitter | ||
| self.session_create_max_retries = ( |
There was a problem hiding this comment.
can probably just set all these things to some value that has a default instead of all the if else (same for the stuff below)
| ModeType = Literal["dom", "cua"] | ||
|
|
||
|
|
||
| def _build_default_cua_system_prompt(viewport_width: int, viewport_height: int) -> str: |
There was a problem hiding this comment.
should leave system prompt stuff to the downstream environment not in the base browserenv
| return dumped | ||
| return None | ||
|
|
||
| async def env_response( |
There was a problem hiding this comment.
what is all this new env resposne stuff for


Description
This PR improves the BrowserEnv CUA path and the bundled Browserbase CUA server by making session creation, retries, and sandbox cleanup more resilient, and by surfacing structured
retryable/validation errors back to the caller.
It also adds viewport-aware default CUA prompting and tool descriptions, fixes CUA
env_responsehandling for empty zero-arg tool calls and screenshot-bearing tool messages, andupdates the browser examples/docs to reflect the new behavior and tuning knobs.
Type of Change
Testing
uv run pytestlocally.Ran
uv run pytest tests/test_browser_env.pylocally (37 passed in 0.13s).New coverage was added for:
env_responsescreenshot relocation and empty tool-arg normalizationI also started
uv run pytest, but it did not complete during this verification window, so the full-suite checkbox is left unchecked.Checklist
Additional Notes
Key additions include dedicated CUA session-creation retry settings, per-environment CUA request concurrency limiting, bounded server-side session-create queueing, and structured
validation errors that give the model repairable feedback for bad action arguments.
Note
Medium Risk
Touches CUA control flow (session creation, retries, error handling, and sandbox cleanup) across both the server and Python client, which can affect rollout stability and retry behavior if misclassified. Changes are well-scoped and backed by new tests, but concurrency/timeout tuning may need validation under real load.
Overview
CUA server now returns structured, retry-aware errors and validates action arguments.
executeActionthrowsActionValidationErrorwith per-field details (e.g., integer pixel coords, non-negativewait), andserver.tsmaps validation/rate-limit/timeout failures to400/429/504withretryableflags and state included on action failures.Session creation is throttled and classified.
sessionManageradds bounded concurrent session creation with a queue (CUA_SESSION_CREATE_MAX_CONCURRENT/CUA_SESSION_CREATE_MAX_PENDING) and surfaces typedSessionCreateErrorcodes/statuses.BrowserEnv CUA path is more resilient and controllable.
CUAModeadds separate retry policies for session creation vs requests, parses structured error payloads to decide retryability, caps per-env concurrent CUA requests (cua_max_concurrent_requests), and cleans up partially-created sandboxes on setup failure; tool descriptions and default CUA prompts are updated to include viewport dimensions and coordinate guidance, andenv_responsenormalizes empty zero-arg tool calls and relocates screenshot parts out of tool messages.Docs/examples are updated accordingly, and new Node + pytest tests cover structured errors, retry classification, prompt/tool descriptions, env_response behavior, and sandbox cleanup.
Written by Cursor Bugbot for commit 3f861d5. This will update automatically on new commits. Configure here.