Repository navigation
Introduce generic tool calling explainer - #375
Conversation
martinthomson
left a comment
There was a problem hiding this comment.
This looks directionally good from my recollection of the discussion.
bvandersloot-mozilla
left a comment
There was a problem hiding this comment.
Also directionally correct from where I sit!
jakearchibald
left a comment
There was a problem hiding this comment.
I haven't done a full review yet, but figured I'd submit what I've got so far.
jakearchibald
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
|
This is looking very good. 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. |
SHA: 7567116 Reason: push, by domfarolino Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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
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}
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}
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}
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.