-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
Currently we cannot race invocations in TypeScript agents because there is no way to abort the invocation promises after getting a winner out of the race. As the other invocation promises remain registered in the runtime, the whole invocation (the caller agent) will not finish until all of these promises also finish.
To solve this, we need the following steps:
- in
wasm-rquickjs, we generate apromise()method for the WASIPollableresource, which under the hood useswstdto await the promise in an asynchronous way. We need anabortablePromise(signal: AbortSignal)variant of this, but it is not clear how to implement this on thewstd/rust futures level. Most likely requires polling the signal on top of monotonic clock subscriptions. - In the TypeScript SDK, we can add an
abortablevariant to the RPC methods (similar to the currenttriggerandschedule) that takes anAbortSignal - Optionally the abortion of an invocation could also try using the cancel pending invocation API to remove an invoke from the agent's pending queue if it has not been started yet.
Note the goal is not to prevent the remove agent to do the invoked method, just to prevent the JS runtime from waiting for it.
With direct support for AbortSignal invocations can be cancellable promises and races done conveniently for exampel with Effect.
Metadata
Metadata
Assignees
Labels
No labels