Skip to content

Signal tool stability with waitForToolsUntil() and ToolChangeEvent - #373

Open
khushalsagar wants to merge 1 commit into
mainfrom
wait-for-tools-until
Open

khushalsagar wants to merge 1 commit into
mainfrom
wait-for-tools-until

Conversation

@khushalsagar

@khushalsagar khushalsagar commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Implement the resolution from #328 (minutes) and #328 (comment):

  • Add the IDL for waitForToolsUntil and toolsReady, and state tracking for the tools-ready state based on pending promises.
  • Wait for tools-ready (up to an implementation-defined timeout) in getTools() and perform an observation.
  • Dispatch a toolchange event (ToolChangeEvent with ready) when tools become not ready and suppress dispatch of this event until tools become ready again.

Note: There's still an open question for the Document lifecycle until which tools are presumed to be not ready.

Part of #328.


Preview | Diff

@khushalsagar

khushalsagar commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

A tangential thing worth taking up in a separate PR: the toolChange notification from register/unregister isn't coalesced well right now. It's triggered for every register/unregister call. Seems like it would be better to do it in a separate task (or microtask?) since in a task the state will be updated by multiple calls and we should dispatch a single event for all those mutations.

@khushalsagar
khushalsagar force-pushed the wait-for-tools-until branch 2 times, most recently from 94b382b to 9f62142 Compare November 3, 2026 20:26

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant