Skip to content

fix(browser): ask for consent before executing a discovered site tool - #4734

Merged
yomgui merged 4 commits into
devfrom
e2e/site-tool-consent
Sep 11, 2026
Merged

yomgui merged 4 commits into
devfrom
e2e/site-tool-consent

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Fixes the webmcp-browser-agent red in the Daytona E2E lane (triage: reports/e2e-red-2026-09-09/triage.md, Cluster 6 / Brief I — "Site-tool consent skipped on Daytona").

Root cause

ipcMain.on("openwork:webmcp:tools-changed") in browser-panel.mjs called invalidateWebMcpTab(tab), which bumps webMcpRevision and deletes every WebMCP tool handle for the tab. That IPC is the preload's relay of the page's registerTool activity, debounced by 250 ms, so on a freshly navigated page it lands ~250 ms after the document script ran — routinely after webmcp_list_tools already returned those same tools.

Sequence in the red nightlies (trace …21-24-36-286Z…/test-run.json seq 149–152): navigate /execution-delay → site_tools lists 5 tools (237 ms) → relay lands → site_tool returns in 223 ms. The broker's executeTool found no handle and threw stale_tool before confirmExecution, so no "Allow once" prompt ever mounted and the spec timed out 30 s later. Whether the relay lands before site_tools or between site_tools and site_tool is pure timing — deterministic under the loaded nightly lane, green in a quiet single-spec run (my first Daytona run of the unchanged product at cfb7b7bc passed, which is why this is a race, not a policy).

Ruled out from the brief:

  • Workspace run mode (94649b44a) / team browser policy (012586824): those only add deny paths (checkPolicy); nothing auto-allows. Steps 5–8 of the same red runs show "Allow once" working on the same page.
  • Engine v1 vs v2: the consent gate lives in the Electron main process (confirmBrowserAction), independent of the engine. The red runs were engine: v1.

What changed

  • apps/desktop/electron/browser-panel.mjs: the tools-changed relay no longer treats a registration change like a navigation. It only schedules the tool-count refresh. Only did-start-navigation bumps the revision. Safety is unchanged: executeTool still re-reads the frame's live tools and compares the descriptor digest before consent, and the in-page dispatcher checks the digest again, so a changed or removed tool is still refused as stale_tool (existing broker test "navigation and descriptor changes invalidate opaque handles" covers this without any revision bump).
  • apps/desktop/electron/browser-panel.test.mjs: the stub webContents gains an origin-keyed mainFrame so the harness can drive site_tools/site_tool. New test: list a tool, emit openwork:webmcp:tools-changed from the tab, then site_tool must mount "Allow website action?" before anything runs; approve execution and result sharing; then a removed tool is still stale_tool. Red on the previous handler (browserApproval undefined), green with the fix.

No spec changes. The journey's claim ("execution approval is asked after navigate + list") is unchanged; it is now independent of relay timing.

Proof

OPENWORK_EVAL_REF=66e8bdb59f8f5e11e61cd581165edc0f0256231f pnpm evals:e2e webmcp-browser-agent --daytona

{"placement":"daytona","engine":"legacy","surface":"legacy","files":["webmcp-browser-agent"],"passed":1,"failed":0,"skipped":0,"verdict":"passed"} — sandbox checked out 66e8bdb5; all 17 steps ok; both sandboxes disposed.

Unit: node --test apps/desktop/electron/browser-panel.test.mjs apps/desktop/electron/webmcp-host.test.mjs apps/desktop/electron/webmcp-policy.test.mjs → 85 passed, 0 failed.

Caveat on the journey as proof of this race: it exercises the "relay between list and execute" ordering only when timing produces it (as the nightly lane did). The panel test pins that ordering deterministically.

Noticed, not touched

  • refreshTabToolCount → onToolsChanged replaces tab.webMcpTools with entries lacking toolId (unlike listTools), so the panel's siteTools payload shape depends on which path ran last.
  • Locally on macOS the spec fails earlier at agent.run("browser.open_url") with "no interactive surface" (composer off-screen in the default local window). Not investigated; Daytona is the proof lane.
  • The two diagnostic commits (cfb7b7bc + its revert d1ec0c67) are left in the branch history as the record of the quiet-lane pass on unchanged product; the net diff is only the two files above.

…ange relay

The preload relays registerTool activity to the host after a 250 ms debounce,
so the notification routinely lands after webmcp_list_tools already returned
those same tools. Treating it like a navigation bumped the tab revision and
deleted every handle, so the next webmcp_call_tool failed as stale_tool
before confirmExecution and the person never saw the Allow once prompt.

Only navigation replaces the document now. Execution still revalidates the
live descriptor digest, so changed or removed tools remain stale_tool.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Sep 10, 2026 3:05am UTC
openwork-den Ignored Ignored Sep 10, 2026 3:05am UTC
openwork-diagnostics Ignored Ignored Sep 10, 2026 3:05am UTC
openwork-landing Ignored Ignored v0 Sep 10, 2026 3:05am UTC

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (55042 ms), confidentiality-review (12158 ms), desktop-den-sync-review (20506 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@diff-warden diff-warden Bot 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (66e8bdb59f8f5e11e61cd581165edc0f0256231f). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

Copy link
Copy Markdown
Contributor

Passed · 3/3 tests · 4/4 assertions · 2 images

Commit 66e8bdb59f8f5e11e61cd581165edc0f0256231f · selected evidence

Open review report

@yomgui
yomgui merged commit 82dfff7 into dev Sep 11, 2026
27 checks passed
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