Skip to content

Commit bc93f03

Browse files
Reject registerTool() promise when signal is aborted (#202)
1 parent 7addecf commit bc93f03

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

index.bs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ To <dfn for="model context">unregister a tool</dfn> given a {{ModelContext}} |mo
258258
1. Let |tool map| be |modelContext|'s [=ModelContext/internal context=]'s [=model context/tool
259259
map=].
260260

261-
1. [=Assert=] |tool map|[|tool name|] [=map/exists=].
261+
1. If |tool map|[|tool name|] does not [=map/exist=], then return.
262262

263263
1. Let |exposed origins| be |tool map|[|tool name|]'s [=tool definition/exposed origins=].
264264

@@ -395,16 +395,20 @@ The <dfn method for=ModelContext>registerTool(<var>tool</var>, <var>options</var
395395
1. Let |untrusted content hint| be true if |tool|'s {{ModelContextTool/annotations}} [=map/exists=] and
396396
its {{ToolAnnotations/untrustedContentHint}} is true. Otherwise, let it be false.
397397

398+
1. Let |promise| be [=a new promise=] created in [=this=]'s [=relevant realm=].
399+
398400
1. Let |signal| be |options|'s {{ModelContextRegisterToolOptions/signal}}.
399401

400402
1. If |signal| [=map/exists=], then:
401403

402-
1. If |signal| is [=AbortSignal/aborted=], then optionally [=report a warning to the console=]
403-
indicating that the tool was not registered because the {{AbortSignal}} was already
404-
[=AbortSignal/aborted=], and return.
404+
1. If |signal| is [=AbortSignal/aborted=], then return [=a promise rejected with=]
405+
|signal|'s [=AbortSignal/abort reason=].
406+
407+
1. [=AbortSignal/add|Add the following abort steps=] to |signal|:
405408

406-
1. [=AbortSignal/add|Add an abort algorithm=] to |signal| that [=model context/unregisters a
407-
tool=] given [=this=] and |tool name|.
409+
1. [=model context/Unregister a tool=] given [=this=] and |tool name|.
410+
411+
1. [=Reject=] |promise| with |signal|'s [=AbortSignal/abort reason=].
408412

409413
1. Let |exposed origins| be an empty [=list=] of [=origins=].
410414

@@ -448,8 +452,6 @@ The <dfn method for=ModelContext>registerTool(<var>tool</var>, <var>options</var
448452

449453
1. Set [=this=]'s [=ModelContext/internal context=][|tool name|] to |tool definition|.
450454

451-
1. Let |promise| be [=a new promise=] created in [=this=]'s [=relevant realm=].
452-
453455
1. Run the following steps [=in parallel=]:
454456

455457
1. [=Notify documents of a tool change=] given |tool owner| and |exposed origins|.

0 commit comments

Comments
 (0)