Repository navigation
Introduce the Tool interface - #348
domfarolino wants to merge 11 commits into
Conversation
|
Binding a A question from the extension side. We discover tools from a content script and have to pass them on to a service worker and an extension page before the model calls one, so a tool has to cross a few contexts. Since A smaller one: as far as I can tell there is no way to change a registered tool, so a changed description is a new |
|
Thanks for the reviews! I'll hold off on landing this for a little bit to give @jakearchibald more time to take a look.
This was broken before this PR too, right @kenchris? (Since
Extensions-specific work or something of the sort will take care of this, right. I don't think it'll propagate to any spec changes here, although we may independently make |
|
Yes, same before, |
This PR introduces the
Toolinterface which encapsulates a tool's new UUID. Tools are now keyed and identified by this ID. This replaces theRegisteredTooldictionary with the newToolinterface, fixes a number of possible race conditions (such as https://webmachinelearning.github.io/webmcp/#unregistration-execution-race), and also unblocks us from being able to execute registered by opaque origin documents (see #349).Note that there are some compatibility changes with this:
RegisteredTool#inputSchemaandRegisteredTool#annotationscould be undefined before this PR, where asTool#inputSchemaandTool#annotationsare notobject?which makes more sense for an interface object. This means these two members can be null when their respective values are not provided. They are never purely undefined now.JSON.stringify(tool)returns{}, and the spread operator copies nothing.structuredClone(tool)throws, since this type is not yet[Serializable].This makes some progress towards the discussion in #236 (/cc @jakearchibald), and helps us out with future worker integration.
/cc @nmccormack-oai from who was interested in this fix from an agent's perspective. Note that the spec still doesn't define a native-agent-initiated tool execution path (equivalent to CDP-initiated tool execution in Chromium, or Gemini-in-Chrome/"actor stack"-initiated tool execution in branded Chrome), but that's coming soon, and the changes here are required to support the correctness / race fixes in those areas too.
Preview | Diff