Skip to content

Fix malformed tool registration and lookup steps - #302

Open
emecii wants to merge 2 commits into
webmachinelearning:mainfrom
emecii:remove-unreachable-signal-check
Open

Fix malformed tool registration and lookup steps#302
emecii wants to merge 2 commits into
webmachinelearning:mainfrom
emecii:remove-unreachable-signal-check

Conversation

@emecii

@emecii emecii commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Clarify registerTool() validation by requiring |tool name| to be a non-empty string and qualifying the description member access with |tool|. The existing aborted-signal checks remain intact so the promise rejection behavior is preserved.

Also replace the malformed If ... be true if step with Let ... be true if in getTools().

Validation: bikeshed --print=plain --dry-run --die-on=warning spec index.bs and make lint pass without warnings. Branch is independent of the input/navigation fix and based on 50c4b7f.


Preview | Diff

`registerTool()` checks the same aborted signal twice. webmachinelearning#240 added an
early check before the `exposedTo` validation but left the original
in place inside the signal block. Between the two, the algorithm only
builds a list of origins, runs the URL parser, and creates a promise —
no step yields to the event loop or invokes author code, so the signal's
aborted flag cannot change and the second check is dead. Removing the
later one preserves webmachinelearning#240's intent, which was to let an aborted signal
win over a `SecurityError`.

`getTools()` reads "If |toolOwnerIsRequested| be true if ...", which
binds nothing; the next step reads that variable, so the step is a
`Let`.

`registerTool()` dereferences a bare {{ModelContextTool/description}}
with no object to read it from. Every other member access in the
algorithm is written |tool|'s {{ModelContextTool/...}}. The |tool name|
half of the same step is already covered by the next step, so this
drops it rather than repeating it.
Comment thread index.bs Outdated
{{InvalidStateError}} {{DOMException}}.

1. If |tool name| or {{ModelContextTool/description}} is an empty string, then return [=a promise
1. If |tool|'s {{ModelContextTool/description}} is the empty string, then return [=a promise

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|tool name| needs to be a non-empty string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 63a8b3e: the validation step now explicitly requires |tool name| to be a non-empty string, while qualifying the description access with |tool|.

Comment thread index.bs

1. Let |signal| be |options|'s {{ModelContextRegisterToolOptions/signal}}.

1. If |signal| is [=AbortSignal/aborted=], then return [=a promise rejected with=]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still required, othwerwise promise is not rejected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored in 63a8b3e so the named promise retains the specified rejection behavior.

Comment thread index.bs

1. If |toolOwnerIsRequested| be true if |targetOrigin| is [=same origin=] with |callerOrigin|,
or if |from origins| [=list/contains=] |targetOrigin|; otherwise, false.
1. Let |toolOwnerIsRequested| be true if |targetOrigin| is [=same origin=] with

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — kept this editorial correction unchanged in 63a8b3e.

@emecii emecii changed the title Remove unreachable aborted-signal check and fix two malformed steps Fix malformed tool registration and lookup steps Sep 11, 2026
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