Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions docs/proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading