Skip to content

Introduce generic tool calling explainer - #375

Open
domfarolino wants to merge 1 commit into
mainfrom
generic-tool-calling
Open

domfarolino wants to merge 1 commit 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.

```js
window.tools.register({
name: "set-profile-picture",
model: {

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.

Suggested change
model: {
naturalLanguageProperties: {

```

The inclusion of `naturalLanguageProperties` directs the browser and other web consumers to expose
the tool to native or external agents via whatever native mechanism or protocol, while `exposedTo`

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.

It's not clear if exposedTo behavior is changing from what we currently in WebMCP spec.

Specifically, since DOMException and the native JavaScript `Error` types are both "serializable",
their standardized JSON lowering can include all of the relevant information that the error object
contains, packaged up into an appropriate JSON representation derived from the serialization. The
serialization will exclude any internal details (like stack traces).

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.

Is it important to distinguish following cases?

await document.modelContext.registerTool({
  name: 'fake_operation_error',
  description: 'desc',
  execute: () => { throw new DOMException('Schema validation failed', 'OperationError') }
});
const [tool] = await document.modelContext.getTools();
await document.modelContext.executeTool(tool);
// throws with a fake OperationError: Schema validation failed

vs

await document.modelContext.registerTool({
  name: 'true_operation_error',
  description: 'desc',
  execute: () => { result: 'string instead of number' } ,
  outputSchema: {
    type: 'object',
    properties: { result: { type: "number" }, }
  }
});
const [tool] = await document.modelContext.getTools();
await document.modelContext.executeTool(tool);
// throws with a real OperationError: Schema validation failed

If so, we may want to introduce a ToolExecutionError returned by executeTool().

This branch has not been deployed

No deployments
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.

2 participants