Fix execute_playwright_code snapshot tip#125
Merged
Merged
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
It's TypeScript's incremental build cache — generated, volatile (re-churns on every tsc run), and shouldn't be versioned. Remove it from tracking and add it to .gitignore so it stays out of diffs.
dprevoznik
force-pushed
the
hypeship/playwright-output-cap
branch
from
July 21, 2026 19:20
68be079 to
e65ad18
Compare
State that the returned value is what's sent back, and use concrete selector examples (h1/main) instead of a SELECTOR placeholder.
Match the docs: execute_playwright_code exposes page, context, and browser.
masnwilliams
approved these changes
Jul 21, 2026
masnwilliams
left a comment
Collaborator
There was a problem hiding this comment.
reviewed — clean. verified the description change against the executor and it's accurate.
src/lib/mcp/tools/playwright.ts:14— new scope claim (page,context,browserall in scope +returnvalue sent back) checks out againstkernel-imagesserver/runtime/playwright-daemon.ts(new AsyncFunction('page','context','browser', code)). steering away from_snapshotForAI()toward scoped extraction is the right call for token cost.ariaSnapshot()example is valid public API..gitignore/tsconfig.tsbuildinfo— housekeeping looks right: ignore the incremental build cache + remove the tracked copy in the same PR.
lgtm 👍
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
execute_playwright_codetool'scodeparam tip recommendedawait page._snapshotForAI()for "a comprehensive page state snapshot." Two problems with that:TypeError: page._snapshotForAI is not a function. Agents then fall back to an even largerbody.innerText().Change
Replaced the tip with a one-liner that lists the in-scope objects, makes the return contract explicit, and steers agents off full-page dumps toward the supported public API:
page/context/browserscope matches the docs. Description-only; no change to execution or output behavior. Typechecks clean.Also
Removed
tsconfig.tsbuildinfofrom tracking and added it to.gitignore— it's a generated, volatile TS build cache that shouldn't be versioned.Follow-ups (not in this PR)
The public docs (
kernel/docs → reference/mcp-server/tools/execute-playwright-code.mdx) and the SDK example repos still reference_snapshotForAI()and need the same fix.Note
Low Risk
Documentation and gitignore-only changes with no runtime or auth impact.
Overview
Updates the
execute_playwright_codeMCP tool’scodeparameter description so agents knowpage,context, andbrowserare in scope and that only thereturnvalue is echoed back. The old tip pointed atpage._snapshotForAI(), which blows up context and isn’t available in the stealth runtime; the new copy steers toward small, targeted reads (locator(...).innerText(), region-scopedariaSnapshot()) instead of whole-page dumps. No execution or API behavior changes—description only.Also stops tracking
tsconfig.tsbuildinfoand adds it to.gitignore, with a minor.gitignorenewline fix formcp-key.pem.Reviewed by Cursor Bugbot for commit b58ed95. Bugbot is set up for automated code reviews on this repo. Configure here.