From f9739259225b19a331802ceedf05c75134f02931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Fri, 27 Mar 2026 10:26:14 +0100 Subject: [PATCH] Remove unregisterTool from proposal --- docs/proposal.md | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/proposal.md b/docs/proposal.md index 0b6d665..9ebd3f0 100644 --- a/docs/proposal.md +++ b/docs/proposal.md @@ -54,27 +54,30 @@ Handling tool calls in the main thread with the option of delegating to workers ### modelContext 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. -The `modelContext`'s `registerTool()` and `unregisterTool()` methods are used to add and remove tools from the agent's context. +The `modelContext`'s `registerTool()` method is used to add and remove tools from the agent's context. ```js -window.navigator.modelContext.registerTool({ - execute: - ({ text }, agent) => { - // Add todo item and update UI. - return /* structured content response */ - }, - name: "add-todo", - description: "Add a new todo item to the list", - inputSchema: { - type: "object", - properties: { - text: { type: "string", description: "The text of the todo item" } - }, - required: ["text"] - }, - }); +const addTodoTool = { + execute: ({ text }, agent) => { + // Add todo item and update UI. + return /* structured content response */ + }, + name: "add-todo", + description: "Add a new todo item to the list", + inputSchema: { + type: "object", + properties: { + text: { type: "string", description: "The text of the todo item" } + }, + required: ["text"] + }, +}; +const controller = new AbortController(); + +window.navigator.modelContext.registerTool(addTodoTool, { signal: controller.signal }); -window.navigator.modelContext.unregisterTool("add-todo"); +// Unregister tool later... +controller.abort(); ``` ### agent