Skip to content

Improve waitForToolsUntil() example - #395

Merged
khushalsagar merged 1 commit into
webmachinelearning:mainfrom
beaufortfrancois:waitForToolsUntil-example
Nov 29, 2026
Merged

khushalsagar merged 1 commit into
webmachinelearning:mainfrom
beaufortfrancois:waitForToolsUntil-example

Conversation

@beaufortfrancois

@beaufortfrancois beaufortfrancois commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

The waitForToolsUntil() example registers tools one after another in a for loop. That doesn't fit what the method is for, which is telling the browser when tool registration is finished:

  • If one registerTool() call rejects, the loop stops early, so the remaining tools are never registered and the promise rejects too soon. The agent ends up seeing only some of the tools.
  • Tool discovery is delayed by the sum of all registration times, not just the slowest one.

This PR uses Promise.allSettled() so all tools register at the same time. The promise passed to waitForToolsUntil() then settles only after every registration has finished, and tools are hidden for no longer than the slowest registration.


Preview | Diff

@beaufortfrancois

Copy link
Copy Markdown
Collaborator Author

@khushalsagar Please review

@khushalsagar
khushalsagar merged commit fbd0012 into webmachinelearning:main Nov 29, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Nov 29, 2026
SHA: fbd0012
Reason: push, by khushalsagar

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants