Skip to content

Introduce generic tool calling explainer - #375

Merged
domfarolino merged 24 commits into
mainfrom
generic-tool-calling
Dec 2, 2026
Merged

domfarolino merged 24 commits into
mainfrom
generic-tool-calling

Conversation

@domfarolino

Copy link
Copy Markdown
Collaborator

This proposal includes three concrete API changes to satisfy great feedback from Mozilla, largely captured in #236 and #237.

Please take a look @jakearchibald, @martinthomson, @bvandersloot-mozilla.

Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved

@martinthomson martinthomson 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.

This looks directionally good from my recollection of the discussion.

Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved

@bvandersloot-mozilla bvandersloot-mozilla 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.

Also directionally correct from where I sit!

Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved

@jakearchibald jakearchibald 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.

I haven't done a full review yet, but figured I'd submit what I've got so far.

Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved
Comment thread generalized-tool-calling.md Resolved

@jakearchibald jakearchibald 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.

As long as the shape and details here continue to be up for discussion, I'm happy for this to land.


Each tool also carries a reference to its source `WindowProxy`. That reference isn't always cross-origin, so for a same-origin frame it gives direct access to the DOM the shadow root was hiding. The closest existing pattern is `postMessage`: a frame inside a shadow tree can already pass its window reference out, but only on purpose. We should likely follow the same principle: by default, subtree discovery doesn't cross shadow boundaries but content inside the shadow tree can opt in to exposing its frames' tools upward.

## Tool Serialization

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.

That's fair, although the current model doesn't work well for grouping & continuation.

That said, I'm happy to discuss it in further issues.

Comment thread generalized-tool-calling.md Resolved
@martinthomson

Copy link
Copy Markdown

This is looking very good.

Is it too late to suggest a last tweak? To the name: "Tool API".

@domfarolino

Copy link
Copy Markdown
Collaborator Author

Is it too late to suggest a last tweak? To the name: "Tool API".

OK so my personal opinion is that we should not rename the API, but also I'd like to hold off on litigating this among web-only folks until we have some more meetings with AAIF / MCP folks, because especially since we're now committing to formalize WebMCP exposure over JSON and over a transport protocol like BiDi, there's a good question as to whether we should make these tools "fit" onto the MCP protocol so that natural language consumers of tools can use legitimate MCP integrations to communicate with WebMCP, and if we can make the two protocols fit more closely together to meet our natural language consumers (agents) where they are. I'd love to discuss this more with both AAIF / MCP folks, as well as browsers, so let's have that discussion first!


Thanks for all the productive discussion on this explainer! I think we're clear to land this now and work out the finer points over GitHub PRs and CG resolutions as they come up, so we'll move forward towards getting everything spec'd now.

@domfarolino
domfarolino merged commit 7567116 into main Dec 2, 2026
2 checks passed
@domfarolino
domfarolino deleted the generic-tool-calling branch December 2, 2026 20:27
github-actions Bot added a commit that referenced this pull request Dec 2, 2026
SHA: 7567116
Reason: push, by domfarolino

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 3, 2026
The WebMCP explainer moves tool registration from document.modelContext
to a new window.toolManager object. Add window.toolManager behind a new
WebMCPv2 runtime flag so it can be developed and tested next to the
existing API. WebMCPv2 is experimental (on for web tests and with
experimental web platform features).

ToolManager is a thin facade over the same per-document ModelContext
core that backs document.modelContext, so both APIs share one tool
registry. See webmachinelearning/webmcp#375 for
the API shape.

The tools permissions policy still applies to window.toolManager, like
document.modelContext. Limiting exposure to the user agent to tools with
natural language properties, and gating only that exposure on the
policy, is tracked in crbug.com/590603017.

A separate ToolManagerRegisterTool use counter tracks migration from
document.modelContext.registerTool() to the new API.

Existing WPTs keep using document.modelContext. They'll move to the new
API in a follow-up, once
webmachinelearning/webmcp#392 is resolved.

Bug: 581478899
Test: blink_unittests ModelContext*:HTMLFormMcpTool*:*WebMCP*
Test: run_web_tests.py external/wpt/webmcp wpt_internal/webmcp
Test: run_web_tests.py fast/webmcp webexposed inspector-protocol/webmcp
Change-Id: I2c50592c4f5aaf9197f6bf3a6d24ffa2c8595441
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Dec 3, 2026
The WebMCP explainer moves tool registration from document.modelContext
to a new window.toolManager object. Add window.toolManager behind a new
WebMCPv2 runtime flag so it can be developed and tested next to the
existing API. WebMCPv2 is experimental (on for web tests and with
experimental web platform features).

ToolManager is a thin facade over the same per-document ModelContext
core that backs document.modelContext, so both APIs share one tool
registry. See webmachinelearning/webmcp#375 for
the API shape.

The tools permissions policy still applies to window.toolManager, like
document.modelContext. Limiting exposure to the user agent to tools with
natural language properties, and gating only that exposure on the
policy, is tracked in crbug.com/590603017.

A separate ToolManagerRegisterTool use counter tracks migration from
document.modelContext.registerTool() to the new API.

Existing WPTs keep using document.modelContext. They'll move to the new
API in a follow-up, once
webmachinelearning/webmcp#392 is resolved.

Bug: 581478899
Test: blink_unittests ModelContext*:HTMLFormMcpTool*:*WebMCP*
Test: run_web_tests.py external/wpt/webmcp wpt_internal/webmcp
Test: run_web_tests.py fast/webmcp webexposed inspector-protocol/webmcp
Change-Id: I2c50592c4f5aaf9197f6bf3a6d24ffa2c8595441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8806158
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1761117}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 3, 2026
The WebMCP explainer moves tool registration from document.modelContext
to a new window.toolManager object. Add window.toolManager behind a new
WebMCPv2 runtime flag so it can be developed and tested next to the
existing API. WebMCPv2 is experimental (on for web tests and with
experimental web platform features).

ToolManager is a thin facade over the same per-document ModelContext
core that backs document.modelContext, so both APIs share one tool
registry. See webmachinelearning/webmcp#375 for
the API shape.

The tools permissions policy still applies to window.toolManager, like
document.modelContext. Limiting exposure to the user agent to tools with
natural language properties, and gating only that exposure on the
policy, is tracked in crbug.com/590603017.

A separate ToolManagerRegisterTool use counter tracks migration from
document.modelContext.registerTool() to the new API.

Existing WPTs keep using document.modelContext. They'll move to the new
API in a follow-up, once
webmachinelearning/webmcp#392 is resolved.

Bug: 581478899
Test: blink_unittests ModelContext*:HTMLFormMcpTool*:*WebMCP*
Test: run_web_tests.py external/wpt/webmcp wpt_internal/webmcp
Test: run_web_tests.py fast/webmcp webexposed inspector-protocol/webmcp
Change-Id: I2c50592c4f5aaf9197f6bf3a6d24ffa2c8595441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8806158
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1761117}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 3, 2026
The WebMCP explainer moves tool registration from document.modelContext
to a new window.toolManager object. Add window.toolManager behind a new
WebMCPv2 runtime flag so it can be developed and tested next to the
existing API. WebMCPv2 is experimental (on for web tests and with
experimental web platform features).

ToolManager is a thin facade over the same per-document ModelContext
core that backs document.modelContext, so both APIs share one tool
registry. See webmachinelearning/webmcp#375 for
the API shape.

The tools permissions policy still applies to window.toolManager, like
document.modelContext. Limiting exposure to the user agent to tools with
natural language properties, and gating only that exposure on the
policy, is tracked in crbug.com/590603017.

A separate ToolManagerRegisterTool use counter tracks migration from
document.modelContext.registerTool() to the new API.

Existing WPTs keep using document.modelContext. They'll move to the new
API in a follow-up, once
webmachinelearning/webmcp#392 is resolved.

Bug: 581478899
Test: blink_unittests ModelContext*:HTMLFormMcpTool*:*WebMCP*
Test: run_web_tests.py external/wpt/webmcp wpt_internal/webmcp
Test: run_web_tests.py fast/webmcp webexposed inspector-protocol/webmcp
Change-Id: I2c50592c4f5aaf9197f6bf3a6d24ffa2c8595441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8806158
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1761117}
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.