Skip to content

Add cookbook: Playwright with computer use fallback - #540

Merged
dprevoznik merged 14 commits into
mainfrom
hypeship/cua-fallback-cookbook
Sep 3, 2026
Merged

Add cookbook: Playwright with computer use fallback#540
dprevoznik merged 14 commits into
mainfrom
hypeship/cua-fallback-cookbook

Conversation

@dprevoznik

@dprevoznik dprevoznik commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a cookbook for starting browser agents with Playwright and switching to computer-use tools only for interactions that need screenshot-based control.
  • Compare three handoff strategies: Per-Tool Limit, Total Tool-Call Limit, and Model-Directed Handoff.
  • Include complete TypeScript examples with matching constants, session IDs, filenames, comments, prompts, and log labels.
  • Add browsers/playwright-computer-use-fallback.mdx to the docs navigation.

Test plan

  • Validate docs.json with jq empty docs.json.
  • Run PUPPETEER_SKIP_DOWNLOAD=true npx --yes mint broken-links.
  • Run mint dev --port 3000 and verify /browsers/playwright-computer-use-fallback returns HTTP 200 and renders all three approach names.

Note

Low Risk
Documentation-only changes with no product or API behavior impact; the Control intro now favors Playwright-first guidance, which may diverge slightly from later sections on the same page that still describe computer-use-first patterns.

Overview
Adds a new cookbook at /browsers/playwright-computer-use-fallback that documents using @onkernel/browser-loop to run DOM-based Playwright tools first and switch to screenshot-based computer-use tools when interactions (e.g. pointer drag-and-drop) fail silently. It walks through one magnitasks.com Kanban task and three handoff patterns: per-tool attempt limits, total Playwright tool-call limits, and model-directed loop.toolsets.mixed() with prompt steering, including full TypeScript samples (KERNEL browser, replay recording, compiled.apply(harness)).

Navigation and positioning: registers the page in docs.json under Intermediate browser guides, and updates introduction/control so the agent recommendation points at this guide (Playwright first, computer use fallback) instead of treating the two modes as peer equals in the opening paragraph.

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

Documents three ways to hand a stuck playwright-mode agent off to
computer use (trigger-tool budget, flat step-count budget, mixed
toolset with a steering prompt) using @onkernel/browser-loop.
cursor[bot]
cursor Bot approved these changes Sep 2, 2026
Comment thread browsers/cua-fallback.mdx Outdated
Avoid naming specific third-party AI products in prose outside a
dedicated integration page.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after ae2154a. The PR is still documentation-only: a new cookbook page (browsers/cua-fallback.mdx) and one docs.json sidebar entry. No application code, API, auth, CI, or infrastructure changes.

The new commit rewrites a single prose sentence to use generic wording instead of naming third-party agent SDKs. No new files, nav changes, or executable paths.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

Renames the file and aligns terminology throughout: "playwright mode"
becomes "code mode" and "CUA mode" becomes "computer use", matching
the new title.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after fb68cc0. The PR remains documentation-only: one new cookbook page and one docs.json sidebar entry. No application code, API, auth, CI, or infrastructure changes.

The new commit renames browsers/cua-fallback.mdxbrowsers/code-mode-fallback.mdx and updates copy/identifiers (playwright modecode mode, CUAcomputer use, matching docs.json path). Same page, same nav slot, no new executable paths.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@dprevoznik dprevoznik changed the title Add cookbook: Playwright mode with a CUA fallback Add cookbook: Using Code Mode with Computer Use Fallback Sep 2, 2026
State plainly that this cookbook uses browser-loop and why its
apply() swap enables the mid-session handoff, and note the same
approach applies to any harness or toolset driving the browser.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 8e9d59f. The PR remains documentation-only: one new cookbook page (browsers/code-mode-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes.

The new commit rewrites two paragraphs in Picking a harness to describe browser-loop / compiled.apply() as explanation rather than endorsement, and to state that the same handoff pattern applies to other harnesses. No new files, nav changes, or executable paths.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

…l framing

Introduces code mode / computer use as the general concept, then
establishes playwright mode / CUA mode as browser-loop's specific
terms and uses them for the rest of the doc, matching the restored
code. Code snippets are restored close to their original source,
with internal-run-specific claims (exact tool-call counts, "verified
directly" framing) generalized.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 37cb336. The PR remains documentation-only: one new cookbook page (browsers/code-mode-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes.

The new commit restores fuller @onkernel/browser-loop example snippets (replay start/stop, longer comments, playwright/CUA naming aligned with the library) and keeps the general code-mode / computer-use framing. Same page, same nav slot, no new files or executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

Playwright mode is browser-loop's specific implementation of the
general code-mode approach, not a synonym introduced alongside it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 608db5c. The PR remains documentation-only: one new cookbook page (browsers/code-mode-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes.

The new commit rewrites a single sentence in Code mode vs. computer use so code mode is framed as the general DOM-ref approach and playwright mode as browser-loop's implementation of it. Same page, same nav slot, no new files or executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@mintlify

mintlify Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Kernel 🟢 Ready View Preview Sep 2, 2026, 10:10 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Comment thread browsers/code-mode-fallback.mdx Outdated
@@ -0,0 +1,507 @@
---
title: "Using Code Mode with Computer Use Fallback"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I think the original version using "Playwright" is clearer, since raf defines code mode as give your agent the ability to write code. So I think we can write a separate guide focused on code mode and revert this all to Playwright, i'm going through now and will push up a commit

@AnnaXWang AnnaXWang changed the title Add cookbook: Using Code Mode with Computer Use Fallback Add cookbook: Using Playwright with CUA Fallback Sep 3, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 3ed9482. The PR remains documentation-only: one new cookbook page (browsers/playwright-cua-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes.

The new commit renames browsers/code-mode-fallback.mdxbrowsers/playwright-cua-fallback.mdx, retitles the page to Using Playwright with CUA Fallback, and swaps remaining “code mode” wording to Playwright/CUA. It also adds a short Playwright intro. Same cookbook, same nav slot, no new executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 167fdb2. The PR remains documentation-only: one new cookbook page (browsers/playwright-cua-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes.

The new commit rewords one intro sentence (toolsframeworks) and adds a two-sentence definition of an agent tool vs. a toolset under Playwright vs. CUA. Same page, same nav slot, no new files or executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after b1a59b1. The PR remains documentation-only: one new cookbook page (browsers/playwright-cua-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit is copy and branding on that same page: title/description wording, CUA → Computer Use in headings and prose, Kernel → KERNEL in comments and example identifiers, and a short harness-section rewrite. Same cookbook, same nav slot, no new files or executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@AnnaXWang AnnaXWang changed the title Add cookbook: Using Playwright with CUA Fallback Add cookbook: Playwright with computer use fallback Sep 3, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 5f33aa2. The PR remains documentation-only: one new cookbook page (browsers/playwright-computer-use-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit renames browsers/playwright-cua-fallback.mdxbrowsers/playwright-computer-use-fallback.mdx, updates the nav slug to match, and standardizes handoff wording (CUA → computer use; Approach A/B/C → Per-Tool Attempt Limit / Total Tool-Call Limit / Model-Directed Handoff). Example snippet identifiers, filenames, log labels, and variable names were renamed to match. Same cookbook, same nav slot, no new executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@AnnaXWang AnnaXWang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the Playwright fallback cookbook to make the terminology clearer. I renamed the three strategies to Per-Tool Limit, Total Tool-Call Limit, and Model-Directed Handoff, let's discuss in Slack if we want to update this more.

I also realized that CUA was an overloaded term. I replaced it everywhere with “computer use” or “computer-use tools” throughout the guide and code examples.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 575fd95. The PR remains documentation-only: one new cookbook page (browsers/playwright-computer-use-fallback.mdx) and one docs.json sidebar entry after Playwright Execution. No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit is copy-only on that same page: Per-Tool Attempt LimitPer-Tool Limit in headings, tables, prose, example comments, session IDs, and suggested filenames. Same cookbook, same nav slot, no new files or executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook page; existing pages unchanged
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

Reframes the agent recommendation as starting with playwright
execution and falling back to computer use, with a link to the new
cookbook that shows the pattern.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after c9b3c7e. The PR remains documentation-only. Current files:

  • new cookbook page browsers/playwright-computer-use-fallback.mdx
  • docs.json sidebar entry after Playwright Execution
  • one-sentence copy change on introduction/control.mdx

No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit only updates the Control intro lead: it points agents at Playwright first with a computer-use fallback, and adds a link to the new cookbook. Same docs surface (Mintlify pages + nav), no new executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook plus a one-line intro recommendation/link
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 1f76b71 (merge of main into this branch). The PR remains documentation-only. Current files unique to this branch vs main:

  • new cookbook page browsers/playwright-computer-use-fallback.mdx
  • docs.json sidebar entry after Playwright Execution
  • one-sentence copy change on introduction/control.mdx

No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit is a merge of already-landed main (Foreman's Vercel KB link and related docs). It does not add files or behavior to this PR's unique surface.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook plus a one-line intro recommendation/link
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk assessment: Very Low

Decision: Approval stands (not re-approved; risk did not increase)

Re-evaluated after 0bb8281. The PR remains documentation-only. Current files unique to this branch vs main:

  • new cookbook page browsers/playwright-computer-use-fallback.mdx
  • docs.json sidebar entry after Playwright Execution
  • copy change on introduction/control.mdx

No application code, API, auth, CI, or infrastructure changes. No CODEOWNERS file in the repo.

The new commit only rewords the Control intro link to the same cookbook (playwright w/ computer use fallback). Same docs surface (Mintlify pages + nav), no new executable paths in this repo.

Factor Assessment
Codepaths modified Docs content + sidebar nav only
Blast radius New Intermediate cookbook plus an intro recommendation/link
Complexity Example TypeScript snippets for readers; not executed by this repo
Infrastructure impact None
Production / shared systems None
CODEOWNERS No CODEOWNERS file in the repo

Example systemPrompt strings in the cookbook are illustrative copy, not deployed model instructions for this site.

Prior approval on affd44c remains in effect. Risk did not increase, so approval is not dismissed and is not re-issued.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@dprevoznik
dprevoznik merged commit 4984029 into main Sep 3, 2026
4 checks passed
@dprevoznik
dprevoznik deleted the hypeship/cua-fallback-cookbook branch September 3, 2026 16:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0bb8281. Configure here.

Comment thread introduction/control.mdx
Kernel browsers expose four ways to drive a session. For agents, we recommend [computer use](/browsers/computer-controls) or [playwright execution](/browsers/playwright-execution) — both run co-located with the browser and avoid the bot-detection surface a direct CDP connection introduces.
Kernel browsers expose four ways to drive a session. For agents, we recommend starting with playwright execution and falling back to computer use, here's our guide: [playwright w/ computer use fallback](/browsers/playwright-computer-use-fallback).

Both run co-located with the browser and avoid the bot-detection surface a direct CDP connection introduces.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Control intro mislinks Playwright Execution

Medium Severity

The Control intro now recommends “playwright execution” and links to the new cookbook, but that page teaches @onkernel/browser-loop DOM tools (loop.toolsets.browser()), not kernel.browsers.playwright.execute(). The following “Both run co-located… avoid… CDP” sentence is no longer true of that path, and it contradicts this page’s later “computer controls for interaction, playwright execution for structured data” guidance.

Fix in Cursor Fix in Web

Triggered by learned rule: Promote Playwright Execution API over direct CDP connections in examples

Reviewed by Cursor Bugbot for commit 0bb8281. Configure here.

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.

2 participants