Fix execute_playwright_code snapshot tip#125
Open
dprevoznik wants to merge 4 commits into
Open
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
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.
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.
masnwilliams
marked this pull request as ready for review
July 21, 2026 17:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
codeparam tip recommendedawait 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 biggerbody.innerText(). This is a big context-window driver onexecute_playwright_code.Swapped it for a one-line tip in the same shape:
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_codetool: thecodeparameter description no longer suggestspage._snapshotForAI()for a full-page snapshot.The tip now tells agents to return only what they need—e.g.
page.locator(SELECTOR).innerText()or scopedpage.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.