Skip to content

Fix execute_playwright_code snapshot tip#125

Open
dprevoznik wants to merge 4 commits into
mainfrom
hypeship/playwright-output-cap
Open

Fix execute_playwright_code snapshot tip#125
dprevoznik wants to merge 4 commits into
mainfrom
hypeship/playwright-output-cap

Conversation

@dprevoznik

@dprevoznik dprevoznik commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The code param tip recommended await page._snapshotForAI() for "a comprehensive page state snapshot." That steers agents toward a whole-page dump — its size scales with page complexity, and it's a Playwright internal that isn't reliably exposed in the execution runtime, so agents call it, it errors, and they fall back to an even bigger body.innerText(). This is a big context-window driver on execute_playwright_code.

Swapped it for a one-line tip in the same shape:

Tip: return only what you need — prefer a targeted selector (e.g. await page.locator(SELECTOR).innerText()) and scope reads to a region (e.g. await page.locator('main').ariaSnapshot()) rather than dumping the whole page.

One-line change to the tool description; no behavior change to execution or output. Typechecks clean.

🤖 Generated with Claude Code


Note

Low Risk
Copy-only change to an MCP tool schema description; no runtime or security impact.

Overview
Documentation-only change to the MCP execute_playwright_code tool: the code parameter description no longer suggests page._snapshotForAI() for a full-page snapshot.

The tip now tells agents to return only what they need—e.g. page.locator(SELECTOR).innerText() or scoped page.locator("main").ariaSnapshot()—instead of dumping the whole page. No change to Playwright execution, handlers, or tool behavior.

Reviewed by Cursor Bugbot for commit e72d06f. Bugbot is set up for automated code reviews on this repo. Configure here.

The tool returned executed-code output verbatim and unbounded, so a single
whole-page read (innerText/ariaSnapshot on body) could dump tens to hundreds
of KB into the model context. The code param also recommended
page._snapshotForAI(), which is a large full-page dump and is not reliably
available in the execution runtime.

- Cap each returned field at 25k chars with a truncation marker that nudges
  toward targeted selectors. Small structured results keep their shape.
- Replace the _snapshotForAI() tip with guidance to scope reads to a selector
  or region.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mcp Ready Ready Preview, Comment Jul 21, 2026 3:24pm

Replace the single all-or-nothing snapshot tip with a broad-to-narrow
workflow: orient cheaply (title + heading outline, or a landmark map of
region/label/control-count), then scope ariaSnapshot to one region, then
extract with a targeted locator. Explicitly warns off whole-page innerText/
ariaSnapshot on body.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dprevoznik dprevoznik changed the title Cap execute_playwright_code output and fix snapshot tip Rework execute_playwright_code tip into a recon funnel (+ output cap) Jul 21, 2026
Trim the recon-funnel walkthrough back to a single Tip: line matching the
original description's shape — prefer targeted selectors and scope reads to a
region instead of dumping the whole page.
@dprevoznik dprevoznik changed the title Rework execute_playwright_code tip into a recon funnel (+ output cap) Fix execute_playwright_code snapshot tip + cap output Jul 21, 2026
Revert the per-field output truncation. The only change vs main is the code
param tip: prefer a targeted selector and scope reads to a region instead of
the removed _snapshotForAI() whole-page snapshot.
@dprevoznik dprevoznik changed the title Fix execute_playwright_code snapshot tip + cap output Fix execute_playwright_code snapshot tip Jul 21, 2026
@masnwilliams
masnwilliams marked this pull request as ready for review July 21, 2026 17:41
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