Skip to content

Treat an omitted executeTool() input as an empty object - #324

Merged
domfarolino merged 6 commits into
webmachinelearning:mainfrom
MiguelsPizza:executetool-omitted-input
Sep 29, 2026
Merged

domfarolino merged 6 commits into
webmachinelearning:mainfrom
MiguelsPizza:executetool-omitted-input

Conversation

@MiguelsPizza

@MiguelsPizza MiguelsPizza commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

@domfarolino @beaufortfrancois I ran into this while writing the polyfill. Not sure what the intended behavior is, but I prefer the fallback:

document.modelContext.executeTool(tool); // this should just work IMO

clanker with the details below:

Right now the spec says calling executeTool(tool) with no input throws a TypeError, but Chrome and WPT run the tool with {}.

The spec used to default to {} too. #251 changed the input's type to any and first kept the default as a step (45afd88), but its last commit removed that step (b755b64) when Chromium moved the default into its C++ code. This PR puts the step back.

One wrinkle: the CL review wanted an explicit undefined to throw, but Web IDL treats it the same as a missing argument, so executeTool(tool, undefined) gets {} too. Chrome already does this.


Preview | Diff

@beaufortfrancois

Copy link
Copy Markdown
Collaborator

Sorry for missing this bit in https://github.com/webmachinelearning/webmcp/pull/251/changes.

@domfarolino WDYT?

@domfarolino domfarolino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, yeah I think this is a bug. The behavior I really wanted in https://crrev.com/c/8250826/comment/43a901d5_d0bb54d8/ was:

  • Missing input arguments would be treated just like executeTool(tool, {}).
  • Explicitly passing undefined, as in executeTool(tool, undefined), would throw an exception.

But Web IDL intentionally treats missing undefined and explicit undefined for optional arguments (with no default) as "missing", so I don't think we can achieve my desired distinction without introducing an overload:

executeTool(tool, options)
executeTool(tool, object inputArguments, options)

But that's not very clean, and I'm not sure it's worth fighting Web IDL's defaults here. So I'm happy with the direction of this PR: converge missing-undefined and explicit-undefined. See the two notes below.

Comment thread index.bs Outdated
Comment thread index.bs Outdated
@domfarolino

Copy link
Copy Markdown
Collaborator

Alright I've pushed up a few changes to address the above. Would like one more person on this thread to give an LGTM and I think we can merge.

@MiguelsPizza

Copy link
Copy Markdown
Contributor Author

LGTM! Thanks folks

@beaufortfrancois beaufortfrancois left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM with nit

Comment thread index.bs Outdated
@anssiko anssiko removed the Agenda+ label Sep 29, 2026
@anssiko

anssiko commented Sep 29, 2026

Copy link
Copy Markdown
Member

I dropped this from the agenda since we're aligned and can land this fix soon. Thanks for the PR!

@domfarolino
domfarolino force-pushed the executetool-omitted-input branch from b516e80 to f955442 Compare September 29, 2026 15:15
@domfarolino
domfarolino merged commit 294bad9 into webmachinelearning:main Sep 29, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Sep 29, 2026
SHA: 294bad9
Reason: push, by domfarolino

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants