Skip to content

docs(browsers): document code constraints for playwright execution#351

Open
MaxFritzhand wants to merge 2 commits intokernel:mainfrom
MaxFritzhand:feature/playwright-execution-constraints
Open

docs(browsers): document code constraints for playwright execution#351
MaxFritzhand wants to merge 2 commits intokernel:mainfrom
MaxFritzhand:feature/playwright-execution-constraints

Conversation

@MaxFritzhand
Copy link
Copy Markdown

@MaxFritzhand MaxFritzhand commented Apr 30, 2026

Description

While building an LLM-driven Playwright goal runner against Kernel's playwright.execute API (gist), I hit two concrete gaps in the current browsers/playwright-execution.mdx doc:

  1. Code constraints aren't documented. playwright.execute injects page/context/browser into a fresh async scope, but generated code reliably breaks the API by importing playwright, calling chromium.launch(), redeclaring those variables, or wrapping in IIFEs. The doc says what's available — not what's forbidden.
  2. Empty-result recovery isn't covered. Today's "Error handling" only addresses success: false. Real agentic flows hit success: true, result: null from selector misses; that pattern deserves a template.

Purely additive: only browsers/playwright-execution.mdx modified — two new H2 sections slotted into the existing structure (after Available variables and after Error handling). All examples include both TypeScript and Python per AGENTS.md.

Implementation Checklist

  • If updating our sample apps, update the info in our Quickstart — N/A, no sample app changes.
  • If updating our CLI, update the info in our CLI — N/A, no CLI changes.

Testing

  • mintlify dev works locally and renders the new sections cleanly.
  • mint broken-links passes locally (same check this repo's CI runs).

Docs

  • Link to a PR in our docs repo documenting your change (if applicable) — N/A, this is the docs repo.

Visual Proof

Local renders of the new sections under mint dev:

Related Issue

N/A — patterns are grounded in the linked goal-runner gist rather than a prior issue.

Additional Notes

The "Recovering from empty results" section is the more opinionated of the two (prescribes a retry pattern). Easy to drop on review if it's out of scope.

…for playwright execution

Add three sections to playwright-execution.mdx surfacing constraints and
patterns that emerged while building an LLM-driven Playwright goal runner
against Kernel's playwright.execute API:

- Code constraints: rules for code passed to `code:` (no imports, no
  redeclaring page/context/browser, no IIFE wrapper, must end with return).
  Important when an LLM generates the snippet.
- Composing multiple executes against one session: each call gets a fresh
  page/context/browser, but session state (cookies, storage, current URL)
  persists. Re-goto defensively between calls.
- Recovering from empty results: response.success can be true with a
  null/empty result when a selector misses; pattern for detecting and
  retrying with stronger waits.

All examples include both TypeScript and Python.
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: This PR only modifies documentation (browsers/playwright-execution.mdx) and does not change API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) as specified in the filter.

To monitor this PR anyway, reply with @firetiger monitor this.

…el verification

Remove the "Composing multiple executes against one session" section added
in c94de29. The section claimed cookies/localStorage/URL persist across
playwright.execute calls within one session, but that behavior wasn't
verified against the API — the existing doc's "fresh context each time"
language suggests Kernel may create a new BrowserContext per execute,
which would invert the claim.

Code constraints and empty-result recovery sections remain — both are
independent of the state model and stand on their own.
@MaxFritzhand MaxFritzhand changed the title docs(browsers): document code constraints and multi-step composition for playwright execution docs(browsers): document code constraints for playwright execution Apr 30, 2026
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