Skip to content

Support getCrossDocumentScriptToolResult#53

Open
swissspidy wants to merge 12 commits intomainfrom
add/cross-document
Open

Support getCrossDocumentScriptToolResult#53
swissspidy wants to merge 12 commits intomainfrom
add/cross-document

Conversation

@swissspidy
Copy link
Collaborator

@swissspidy swissspidy commented Mar 3, 2026

Fixes #48

Extended the french-bistro site to optionally perform a navigation for the form submission.

@swissspidy swissspidy requested a review from Kulikowski March 3, 2026 14:46
@swissspidy swissspidy marked this pull request as ready for review March 3, 2026 14:46
Kulikowski

This comment was marked as outdated.

@Kulikowski Kulikowski dismissed their stale review March 3, 2026 22:11

Still investigating issue with form submit

Copy link
Collaborator

@beaufortfrancois beaufortfrancois left a comment

Choose a reason for hiding this comment

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

Thanks for adding cross-document support Pascal.

I've only reviewed demos/ and evals-cli/examples/french-bistro for now.

validateForm();

if (formValidationErrors.length && e.respondWith) {
e.respondWith(formValidationErrors);
Copy link
Collaborator

Choose a reason for hiding this comment

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

respondWith doesn't exist in toolactivated event. I think it should be removed unless you use this somehow.

}

if (isCrossDocument) {
// Trigger native form submission to navigate to result.html
Copy link
Collaborator

Choose a reason for hiding this comment

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

cross document should not mean automatic submission. The user still needs to review what is about to be submitted and click the button.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can remove this entire block if/else


### Variation

When visiting `index.html?crossdocument`, the form submission triggers a navigation to `result.html`. This can be used to demonstrate cross-document tool execution.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Current code suggests you need ?crossdocument=1. If you want this, I'd suggest using params.has('crossdocument') instead of params.get('crossdocument') !== null

return;
}

if (isCrossDocument) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

form.requestSubmit(); should be called there.

e.preventDefault();
form?.addEventListener('submit', function (e) {
if (!isCrossDocument) {
e.preventDefault();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's always call preventDefault() there and remove the one after line 35

});

// On result.html, fill the modal with the reservation details.
if (location.pathname.includes('/result.html')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about moving this block in results.html to not pollute script.js?

@@ -0,0 +1,3 @@
This directory contains evaluation test cases for the [WebMCP french-bistro!](../../../demos/french-bistro/) demo.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we expand a bit on how we can test both versions of this demo (same-document and cross-document) and results should hopefully be the same?

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.

[Feature Request] Support cross-document tool evaluation

3 participants