Skip to content

stagehand-python@4.1.0a0.dev1495

@seanmcguire12 seanmcguire12 tagged this 03 Sep 12:26
# why
before this PR, WebMCP tools registered inside of iframes were unable to
be discovered or invoked
# what changed
- changed WebMCP discovery to enable and collect tools from the page's
main CDP session and every adopted OOPIF session
- routed invocation, response handling, & cancellation through the CDP
session that owns the tool's frame
- stale tools are now rejected instead of falling back to the main
frame, & only affected invocations are cleaned up when an OOPIF detaches
- added extension coverage for cross-session discovery, invocation,
cancellation, response correlation, frame detachment, disposal, &
lifecycle races

# test plan
- [x] Extension discovery tests cover combined main/OOPIF snapshots,
child-session removals, stable session snapshots, next-call discovery
after adoption, & listener cleanup after child enable failure.
- [x] Extension invocation tests cover child-session invocation,
response, cancellation, wrong-session events, targeted detach cleanup,
detach during command setup, page disposal, duplicate invocation IDs,
unknown frames, & failed-command listener cleanup.
- [x] Browser integration coverage verifies distinct main/child CDP
targets and sessions, successful iframe tool discovery and invocation,
structured output, & stale-tool rejection after iframe removal.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
WebMCP tools registered in out-of-process iframes (OOPIFs) are now
discoverable and invokable; previously iframe tools were invisible and
unusable. Invocation, response handling, and cancellation use the CDP
session that owns the frame, while stale or detached frames fail instead
of falling back to the main frame.

- Discovery enables WebMCP on the main session and adopted OOPIF
sessions, then combines their snapshots.
- Detaching an OOPIF rejects only its pending invocations and removes
its listeners.
- Added extension and SDK integration coverage for cross-session
lifecycle, cleanup, and iframe removal.

<sup>Written for commit 2a0744a81fe333b254092ddbf6bd7db9c4f2e2e8.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/2878?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->
Assets 2
Loading