Skip to content

Fire toolactivated after invoking execute #332

Open

Description

@beaufortfrancois

The imperative execute steps fire toolactivated before invoking the tool's execute callback.

Chromium and WPT both do it the other way around:

Proposal: move the step after the call to execute, and add a guard:

 1. Let |toolPromise| be the result of [=invoke|invoking=] |tool|'s {{ModelContextTool/execute}} with
    |inputObject| and |options|.

+1. [=Fire an event=] named {{ModelContext/toolactivated}} at |targetDocument|'s [=Document/associated
+   ModelContext|associated <code>ModelContext</code>=], using {{ToolActivatedEvent}}, with its
+   {{ToolActivatedEvent/toolName}} attribute initialized to |tool|'s {{ModelContextTool/name}}.
+
 1. [=promise/React=] to |toolPromise|:

Related: #126, #245.

Activity

  1. beaufortfrancois commented on Oct 1, 2026

    @beaufortfrancois
    CollaboratorAuthor

    @domfarolino If that makes sense to you, I'll open a spec PR to fix this.

  2. beaufortfrancois commented on Oct 15, 2026

    @beaufortfrancois
    CollaboratorAuthor

    FYI I've discovered this issue when adding support for ToolActivatedEvent and ToolCancelEvent to the WebMCP polyfill in webmachinelearning/webmcp-polyfill#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions