Repository navigation
Handle same-name re-registration during input serialization - #347
Merged
Merged
Conversation
khushalsagar
approved these changes
Oct 14, 2026
github-actions Bot
added a commit
that referenced
this pull request
Oct 15, 2026
SHA: 3279798 Reason: push, by domfarolino Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
brave-builds
pushed a commit
to brave/chromium
that referenced
this pull request
Oct 15, 2026
`registerTool()` rejects a duplicate tool name up front, but then serializes `inputSchema`, which can run script (via `toJSON()`) that registers another tool with the same name. `registerTool()` then still sends the duplicate to the browser, which kills the renderer. Check for a duplicate name again after serialization, next to the existing document-activity re-check, and reject with the same `InvalidStateError` as the up-front check. See webmachinelearning/webmcp#347 for the spec fix. R=khushalsagar Bug: 573722078 Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8583183 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1719227}
beckysiegel
pushed a commit
to chromium/chromium
that referenced
this pull request
Oct 15, 2026
…inputSchema" This reverts commit bbf0329. Reason for revert: LUCI Bisection has identified this change as the culprit of a build failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/compile-analysis/b/8667914546796401745 Sample failed build: https://ci.chromium.org/b/8667914546796401745 If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F8583183&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Fcompile-analysis%2Fb%2F8667914546796401745&type=BUG Original change's description: > WebMCP: Re-check for a duplicate tool name after serializing inputSchema > > `registerTool()` rejects a duplicate tool name up front, but then > serializes `inputSchema`, which can run script (via `toJSON()`) that > registers another tool with the same name. `registerTool()` then still > sends the duplicate to the browser, which kills the renderer. > > Check for a duplicate name again after serialization, next to the > existing document-activity re-check, and reject with the same > `InvalidStateError` as the up-front check. > > See webmachinelearning/webmcp#347 for the spec > fix. > > R=khushalsagar > > Bug: 573722078 > Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8583183 > Commit-Queue: Dominic Farolino <dom@chromium.org> > Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1719227} > Bug: 573722078 No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I76d0fe146b570f7b8590eaadea632794afe24ea3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8575491 Commit-Queue: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Bot-Commit: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Owners-Override: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1719232}
chromium-wpt-export-bot
pushed a commit
to web-platform-tests/wpt
that referenced
this pull request
Oct 15, 2026
`registerTool()` rejects a duplicate tool name up front, but then serializes `inputSchema`, which can run script (via `toJSON()`) that registers another tool with the same name. `registerTool()` then still sends the duplicate to the browser, which kills the renderer. Check for a duplicate name again after serialization, next to the existing document-activity re-check, and reject with the same `InvalidStateError` as the up-front check. See webmachinelearning/webmcp#347 for the spec fix. R=khushalsagar Bug: 573722078 Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8583183 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1719227}
chromium-wpt-export-bot
pushed a commit
to web-platform-tests/wpt
that referenced
this pull request
Oct 15, 2026
`registerTool()` rejects a duplicate tool name up front, but then serializes `inputSchema`, which can run script (via `toJSON()`) that registers another tool with the same name. `registerTool()` then still sends the duplicate to the browser, which kills the renderer. Check for a duplicate name again after serialization, next to the existing document-activity re-check, and reject with the same `InvalidStateError` as the up-front check. See webmachinelearning/webmcp#347 for the spec fix. R=khushalsagar Bug: 573722078 Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8583183 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1719227}
chromium-wpt-export-bot
pushed a commit
to web-platform-tests/wpt
that referenced
this pull request
Oct 15, 2026
…inputSchema" This reverts commit bbf032940645a5dcea55e6dc1bdb34b8c989650f. Reason for revert: LUCI Bisection has identified this change as the culprit of a build failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/compile-analysis/b/8667914546796401745 Sample failed build: https://ci.chromium.org/b/8667914546796401745 If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F8583183&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Fcompile-analysis%2Fb%2F8667914546796401745&type=BUG Original change's description: > WebMCP: Re-check for a duplicate tool name after serializing inputSchema > > `registerTool()` rejects a duplicate tool name up front, but then > serializes `inputSchema`, which can run script (via `toJSON()`) that > registers another tool with the same name. `registerTool()` then still > sends the duplicate to the browser, which kills the renderer. > > Check for a duplicate name again after serialization, next to the > existing document-activity re-check, and reject with the same > `InvalidStateError` as the up-front check. > > See webmachinelearning/webmcp#347 for the spec > fix. > > R=khushalsagar > > Bug: 573722078 > Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8583183 > Commit-Queue: Dominic Farolino <dom@chromium.org> > Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1719227} > Bug: 573722078 No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I76d0fe146b570f7b8590eaadea632794afe24ea3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8575491 Commit-Queue: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Bot-Commit: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Owners-Override: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1719232}
beckysiegel
pushed a commit
to chromium/chromium
that referenced
this pull request
Oct 15, 2026
…inputSchema" This is a reland of commit bbf0329, which was reverted in 8a0f949 for breaking the build. The original CL was written against a `ModelContext` whose `tool_map_` was keyed by tool name, and checked for a duplicate with `tool_map_.find(tool->name())`. https://crrev.com/c/8510757 landed in between and changed `tool_map_` to be keyed by tool ID, so that no longer compiled. The reland uses `FindToolDataByName()`, just like the up-front duplicate check does. Original change's description: > WebMCP: Re-check for a duplicate tool name after serializing inputSchema > > `registerTool()` rejects a duplicate tool name up front, but then > serializes `inputSchema`, which can run script (via `toJSON()`) that > registers another tool with the same name. `registerTool()` then still > sends the duplicate to the browser, which kills the renderer. > > Check for a duplicate name again after serialization, next to the > existing document-activity re-check, and reject with the same > `InvalidStateError` as the up-front check. > > See webmachinelearning/webmcp#347 for the spec > fix. > > R=khushalsagar > > Bug: 573722078 > Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 R=khushalsagar Bug: 573722078 Change-Id: I6b07f7ba6900724d4695ac5f3ee4524e0149736c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8587455 Commit-Queue: Dominic Farolino <dom@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Auto-Submit: Dominic Farolino <dom@chromium.org> Reviewed-by: Fr <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/main@{#1719748}
chromium-wpt-export-bot
pushed a commit
to web-platform-tests/wpt
that referenced
this pull request
Oct 15, 2026
…inputSchema" This is a reland of commit bbf032940645a5dcea55e6dc1bdb34b8c989650f, which was reverted in 8a0f949dda972 for breaking the build. The original CL was written against a `ModelContext` whose `tool_map_` was keyed by tool name, and checked for a duplicate with `tool_map_.find(tool->name())`. https://crrev.com/c/8510757 landed in between and changed `tool_map_` to be keyed by tool ID, so that no longer compiled. The reland uses `FindToolDataByName()`, just like the up-front duplicate check does. Original change's description: > WebMCP: Re-check for a duplicate tool name after serializing inputSchema > > `registerTool()` rejects a duplicate tool name up front, but then > serializes `inputSchema`, which can run script (via `toJSON()`) that > registers another tool with the same name. `registerTool()` then still > sends the duplicate to the browser, which kills the renderer. > > Check for a duplicate name again after serialization, next to the > existing document-activity re-check, and reject with the same > `InvalidStateError` as the up-front check. > > See webmachinelearning/webmcp#347 for the spec > fix. > > R=khushalsagar > > Bug: 573722078 > Change-Id: I044e3ad96fb00c624829eb182047aa30575f81a6 R=khushalsagar Bug: 573722078 Change-Id: I6b07f7ba6900724d4695ac5f3ee4524e0149736c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8587455 Commit-Queue: Dominic Farolino <dom@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Auto-Submit: Dominic Farolino <dom@chromium.org> Reviewed-by: Fr <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/main@{#1719748}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix registerTool()'s duplicate tool name check, which can go stale during
inputSchemaserializationregisterTool()checks whether a tool with the same name already exists before serializinginputSchema. But serialization can run script (e.g., atoJSON()method), and that script can register another tool with the same name in the meantime. The algorithm would then go on to overwrite that tool's entry in the tool map.This PR re-checks the tool map after serialization, right next to the "fully active" re-check added in #345, and rejects with an
InvalidStateError, just like the up-front check.Example: