fix(community): IBM WatsonX ChatWatsonx does not cancel requests on AbortSignal #9225
+126
−6
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.
Description
Fixes IBM WatsonX ChatWatsonx integration to properly handle AbortSignal by passing the signal parameter through to the underlying IBM SDK methods, enabling true server-side request cancellation.
Issue
Fixes a bug where abort signals were accepted but not actually passed to the IBM SDK, causing:
This is the same bug pattern as:
auto:bug
)auto:bug
)Both issues involved signals being passed to AsyncCaller but not to the underlying provider SDK.
Changes
Added
signal: options?.signal
to 4 SDK method calls:Non-streaming methods (_generate):
Streaming methods (_streamResponseChunks):
Also removed ineffective manual abort checks that happened after requests completed.
Technical Details
The IBM WatsonX SDK already supports AbortSignal via the
DefaultParams
interface:Signal flow:
options.signal
Testing
Added 4 unit tests to verify signal is passed to all SDK methods:
textChat()
with projectIddeploymentsTextChat()
with idOrNametextChatStream()
with projectIddeploymentsTextChatStream()
with idOrNameDocumentation Reference
Per https://js.langchain.com/docs/how_to/cancel_execution/:
This PR fixes the "missing implementation" for IBM WatsonX by using the SDK's signal support.