Summary
Several async methods accept a CancellationToken parameter but either ignore it, pass CancellationToken.None instead, or use the wrong token. This means callers cannot cancel operations even when they provide a token.
Locations
Passes CancellationToken.None instead of the provided parameter
Teams.AI.Models.OpenAI/OpenAIChatModel.Send.cs:51 — ChatClient.CompleteChatAsync(chatMessages, requestOptions, CancellationToken.None) ignores the cancellationToken parameter received at line 27
Teams.AI.Models.OpenAI/OpenAIChatModel.Send.cs:92 — ChatClient.CompleteChatStreamingAsync(chatMessages, requestOptions, CancellationToken.None) ignores the cancellationToken parameter received at line 71
Uses wrong token (context property instead of parameter)
Teams.Apps/Contexts/Context.Send.cs:64 — await Sender.Send(activity, Ref, CancellationToken) uses the context's CancellationToken property instead of the cancellationToken method parameter
Token not propagated to underlying call
Teams.Common/Http/HttpClient.cs:60 — await _client.SendAsync(httpRequest) does not pass the available cancellationToken to the underlying HttpClient.SendAsync
Token accepted but unused
Teams.Common/Http/HttpClient.cs:121, 146 — CreateResponse methods accept CancellationToken but never use it
Missing from interface method
Teams.AI/ChatPlugin.cs:69 — OnBuildInstructions is the only method in the interface missing a CancellationToken parameter (all other methods have one)
Teams.AI/BaseChatPlugin.cs:39 — Corresponding base implementation also missing the parameter
Impact
- OpenAI API calls are effectively uncancellable — request timeouts and graceful shutdown cannot abort in-flight calls
- The
Context.Send bug means per-call cancellation tokens passed by callers are silently ignored
- HTTP calls in
Teams.Common cannot be cancelled at the transport level
Suggested fix
- Replace
CancellationToken.None with the cancellationToken parameter
- Fix the parameter shadowing in
Context.Send.cs
- Propagate the token through
HttpClient.SendAsync and CreateResponse
- Add
CancellationToken to OnBuildInstructions interface method
Summary
Several async methods accept a
CancellationTokenparameter but either ignore it, passCancellationToken.Noneinstead, or use the wrong token. This means callers cannot cancel operations even when they provide a token.Locations
Passes
CancellationToken.Noneinstead of the provided parameterTeams.AI.Models.OpenAI/OpenAIChatModel.Send.cs:51—ChatClient.CompleteChatAsync(chatMessages, requestOptions, CancellationToken.None)ignores thecancellationTokenparameter received at line 27Teams.AI.Models.OpenAI/OpenAIChatModel.Send.cs:92—ChatClient.CompleteChatStreamingAsync(chatMessages, requestOptions, CancellationToken.None)ignores thecancellationTokenparameter received at line 71Uses wrong token (context property instead of parameter)
Teams.Apps/Contexts/Context.Send.cs:64—await Sender.Send(activity, Ref, CancellationToken)uses the context'sCancellationTokenproperty instead of thecancellationTokenmethod parameterToken not propagated to underlying call
Teams.Common/Http/HttpClient.cs:60—await _client.SendAsync(httpRequest)does not pass the availablecancellationTokento the underlyingHttpClient.SendAsyncToken accepted but unused
Teams.Common/Http/HttpClient.cs:121, 146—CreateResponsemethods acceptCancellationTokenbut never use itMissing from interface method
Teams.AI/ChatPlugin.cs:69—OnBuildInstructionsis the only method in the interface missing aCancellationTokenparameter (all other methods have one)Teams.AI/BaseChatPlugin.cs:39— Corresponding base implementation also missing the parameterImpact
Context.Sendbug means per-call cancellation tokens passed by callers are silently ignoredTeams.Commoncannot be cancelled at the transport levelSuggested fix
CancellationToken.Nonewith thecancellationTokenparameterContext.Send.csHttpClient.SendAsyncandCreateResponseCancellationTokentoOnBuildInstructionsinterface method