From cc15c8464753b4d525c0238141b135c738c6456b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Mon, 2 Nov 2026 14:49:30 +0100 Subject: [PATCH] Fire toolactivated after invoking execute Fires the toolactivated event after invoking the tool's execute callback, so listeners observe the tool's synchronous effects. This matches Chromium and WPT. Fixes #332 --- index.bs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 847677e..dbf6ed4 100644 --- a/index.bs +++ b/index.bs @@ -570,10 +570,6 @@ internal value=] |uuid|, run these steps: 1. If |inputObject| [=Object type|is not an Object=], then run |completionSteps| given null and [=tool execution error/invalid input=], and abort these steps. -1. [=Fire an event=] named {{ModelContext/toolactivated}} at |targetDocument|'s [=Document/associated - ModelContext|associated ModelContext=], using {{ToolActivatedEvent}}, with its - {{ToolActivatedEvent/toolName}} attribute initialized to |tool|'s {{ModelContextTool/name}}. - 1. Let |controller| be a [=new=] {{AbortController}} created in |targetDocument|'s [=relevant realm=]. @@ -593,6 +589,10 @@ internal value=] |uuid|, run these steps: 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 ModelContext=], using {{ToolActivatedEvent}}, with its + {{ToolActivatedEvent/toolName}} attribute initialized to |tool|'s {{ModelContextTool/name}}. + 1. [=promise/React=] to |toolPromise|: - If |toolPromise| was fulfilled with value |v|: @@ -1463,7 +1463,8 @@ that must be supported, as [=event handler IDL attributes=], by all {{ModelConte

ToolActivatedEvent Interface

The {{ToolActivatedEvent}} interface represents a {{ModelContext/toolactivated}} event that is -dispatched at a {{ModelContext}} object when the execution of a tool begins. +dispatched at a {{ModelContext}} object after a tool's {{ModelContextTool/execute}} callback is +invoked. [Exposed=Window, SecureContext]