Skip to content

Conversation

@Burry
Copy link

@Burry Burry commented Dec 9, 2025

Changes

  • Filter out base64 image data from the screenshot result to reduce context usage.
  • Extract file paths from text content and attach guidance.

See #104

I have emailed [email protected] with a signed CLA.

- Filter out base64 image data from the `screenshot` result to reduce context usage.
- Extract file paths from text content and attach guidance.
@Burry Burry force-pushed the fix/screenshot-context branch from a7e4b0d to 287d15f Compare December 9, 2025 21:16
Copy link
Contributor

@gaojude gaojude left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this issue! However, I discovered that playwright-mcp actually has a built-in flag for this use case.

Better Solution: --image-responses Flag

Instead of filtering the response after the fact, we can prevent the base64 image data from being sent in the first place by using the --image-responses flag when starting the playwright-mcp server:

// In src/_internal/browser-eval-manager.ts:66
const args: string[] = [
  "@playwright/mcp@latest",
  "--image-responses", "omit"  // Add this
]

Why This Approach is Better

  1. Cleaner - Prevents image data at the source rather than filtering after transmission
  2. More efficient - Never transmits base64 data over the stdio transport in the first place
  3. Simpler - No need for filtering logic, regex parsing, or unit tests
  4. More reliable - Doesn't depend on parsing text formats that might change

The screenshot will still be saved to disk (as your tests confirm), and the response will include the file path in the text - we just won't get the massive base64 blob consuming context.

Reference

The --image-responses flag accepts:

  • "allow" (default) - sends base64 image data
  • "omit" - excludes base64 image data from responses
  • "auto" - sends images only if client can display them

See the playwright-mcp documentation for more details.

Would you be interested in updating this PR to use the flag approach instead?

@Burry Burry force-pushed the fix/screenshot-context branch from 9ec4149 to f0bf89e Compare December 14, 2025 00:15
@Burry
Copy link
Author

Burry commented Dec 14, 2025

@gaojude Thanks for the review. Good find—that's much cleaner! I just pushed a change to use that flag.

@Burry Burry requested a review from gaojude December 14, 2025 00:30
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