Skip to content

Fm/debug examples#916

Open
filip-michalsky wants to merge 5 commits intoPrimeIntellect-ai:mainfrom
filip-michalsky:fm/debug-examples
Open

Fm/debug examples#916
filip-michalsky wants to merge 5 commits intoPrimeIntellect-ai:mainfrom
filip-michalsky:fm/debug-examples

Conversation

@filip-michalsky
Copy link
Contributor

@filip-michalsky filip-michalsky commented Feb 15, 2026

Description

Two fixes for the BrowserEnv CUA mode and a DX improvement for the DOM example:

  1. Fix screenshot passing in CUA messages: Screenshots attached as image_url parts inside tool messages were being dropped by clients. The new env_response override in
    BrowserEnv relocates image_url parts out of tool messages into a trailing UserMessage so they are preserved. Also normalizes empty tool-call arguments to "{}" to prevent
    json.loads("") decode failures on zero-arg tools (e.g. screenshot).

  2. Make filter_screenshots_in_messages robust to mixed content types: Content parts can be plain dicts or Pydantic objects. Updated type checks in CUAMode to handle both
    via _get_item_type() helper and getattr fallback.

  3. DX improvement for DOM example: Made project_id optional in load_environment() — it now falls back to the BROWSERBASE_PROJECT_ID env var at runtime. Removed the
    upfront env-var validation that eagerly errored before the environment was even used.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

Files changed:

  • environments/browser_dom_example/browser_dom_example.py — make project_id optional, remove eager env-var check
  • verifiers/envs/integrations/browser_env/browser_env.py — new env_response override: sanitize empty tool args + relocate screenshots from tool messages to user messages
  • verifiers/envs/integrations/browser_env/modes/cua_mode.py — handle dict and Pydantic content parts in filter_screenshots_in_messages

Note

Medium Risk
Touches BrowserEnv.env_response message post-processing in CUA mode, which can affect how tool outputs and multimodal context are presented to models; changes are targeted and covered by new tests but impact core browser-agent I/O.

Overview
Fixes CUA-mode message post-processing so screenshots and tool calls survive provider/adaptor quirks. BrowserEnv.env_response now (1) normalizes empty tool_call.arguments to {} for zero-arg tools and (2) extracts image_url parts from ToolMessage content and appends them as a trailing UserMessage, leaving non-image tool content intact.

Hardens screenshot filtering and improves example DX. CUAMode.filter_screenshots_in_messages now handles content parts that are dicts or Pydantic objects, and the DOM example’s load_environment() makes project_id optional while removing eager env-var validation. New tests cover the CUA env_response relocation behavior and the no-images case.

Written by Cursor Bugbot for commit fa40f0b. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

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.

1 participant