Skip to content

Commit 90daeee

Browse files
Remove unregisterTool() from proposal explainer (#156)
1 parent 6708e33 commit 90daeee

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

docs/proposal.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,30 @@ Handling tool calls in the main thread with the option of delegating to workers
5454
### modelContext
5555
The `window.navigator.modelContext` interface is introduced for the site to declare functionality that can be used by an AI Agent. Access to these tools is arbitrated by the browser.
5656

57-
The `modelContext`'s `registerTool()` and `unregisterTool()` methods are used to add and remove tools from the agent's context.
57+
The `modelContext`'s `registerTool()` method is used to add and remove tools from the agent's context.
5858

5959
```js
60-
window.navigator.modelContext.registerTool({
61-
execute:
62-
({ text }, agent) => {
63-
// Add todo item and update UI.
64-
return /* structured content response */
65-
},
66-
name: "add-todo",
67-
description: "Add a new todo item to the list",
68-
inputSchema: {
69-
type: "object",
70-
properties: {
71-
text: { type: "string", description: "The text of the todo item" }
72-
},
73-
required: ["text"]
74-
},
75-
});
60+
const addTodoTool = {
61+
execute: ({ text }, agent) => {
62+
// Add todo item and update UI.
63+
return /* structured content response */
64+
},
65+
name: "add-todo",
66+
description: "Add a new todo item to the list",
67+
inputSchema: {
68+
type: "object",
69+
properties: {
70+
text: { type: "string", description: "The text of the todo item" }
71+
},
72+
required: ["text"]
73+
},
74+
};
75+
const controller = new AbortController();
76+
77+
window.navigator.modelContext.registerTool(addTodoTool, { signal: controller.signal });
7678

77-
window.navigator.modelContext.unregisterTool("add-todo");
79+
// Unregister tool later...
80+
controller.abort();
7881
```
7982

8083
### agent

0 commit comments

Comments
 (0)