Skip to content

Fix broken _snapshotForAI() tip in execute_playwright_code#126

Closed
masnwilliams wants to merge 1 commit into
mainfrom
hypeship/fix-playwright-snapshot-hint
Closed

Fix broken _snapshotForAI() tip in execute_playwright_code#126
masnwilliams wants to merge 1 commit into
mainfrom
hypeship/fix-playwright-snapshot-hint

Conversation

@masnwilliams

@masnwilliams masnwilliams commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

The execute_playwright_code tool description tells users:

Tip: Use await page._snapshotForAI() for a comprehensive page state snapshot.

That method does not exist in the browser runtime — calling it throws TypeError: page._snapshotForAI is not a function. The runtime drives the browser through a stealth-patched Playwright engine, which strips the internal _snapshotForAI() binding (and page.accessibility.snapshot()).

This updates the hint to the supported public API, page.locator("body").ariaSnapshot(), which returns the page accessibility tree and works in the current runtime.

Verification

Ran against a live browser session:

  • page._snapshotForAI()TypeError: page._snapshotForAI is not a function
  • page.accessibility.snapshot()TypeError (namespace absent)
  • page.locator("body").ariaSnapshot() → returns the aria/accessibility tree ✅

Description-only change; no runtime behavior affected.

Follow-ups (not in this PR)

  • The public docs mirror the same tip: kernel/docs → reference/mcp-server/tools/execute-playwright-code.mdx
  • Several example repos still call _snapshotForAI() in their own code (e.g. kernel-ai-sdk-agent, ImmortalBard)

Note

Low Risk
Documentation string change on an MCP tool schema only; no execution or security impact.

Overview
Updates the execute_playwright_code MCP tool’s code parameter description so the snapshot tip points at page.locator("body").ariaSnapshot() instead of page._snapshotForAI(), which is not available in Kernel’s browser runtime.

This is a description-only change; tool execution and Playwright behavior are unchanged.

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

The page._snapshotForAI() internal method is not available in the
browser runtime, so the tool hint pointed users at a call that throws
"page._snapshotForAI is not a function". Point it at the supported
locator.ariaSnapshot() instead, which returns the page accessibility
tree.

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 5:32pm

@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