Skip to content

.Net: Add cancellation token & add headers to request - #11900

Merged
SergeyMenshykh merged 3 commits into
microsoft:mainfrom
SergeyMenshykh:add-cancellation-token
May 6, 2025
Merged

SergeyMenshykh merged 3 commits into
microsoft:mainfrom
SergeyMenshykh:add-cancellation-token

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Motivation, Context and Description

This PR:

  1. Propagates the cancellation token from all kernel functions of the SessionsPythonPlugin plugin down to the APIs they call.
  2. Refactors the way the plugin adds headers to the request. Instead of adding them as default headers of the HTTP client, they are now added as request headers. The result is the same - the headers are sent each call of any kernel function of the plugin. This change may save time later by preventing bug troubleshooting if/when an HTTP client is injected into the plugin and it sets default headers to the client it does not own.
  3. Replaces the usage of HTTP client methods for getting content, such as ReadAsStringAsync, with the SK wrappers ReadAsStringWithExceptionMappingAsync to align the plugin's behavior with that of other SK components.

Contributes to: #10070

@SergeyMenshykh SergeyMenshykh self-assigned this May 6, 2025
@SergeyMenshykh
SergeyMenshykh requested a review from a team as a code owner May 6, 2025 08:51
@SergeyMenshykh SergeyMenshykh added the .NET Issue or Pull requests regarding .NET code label May 6, 2025
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the kernel Issues or pull requests impacting the core kernel label May 6, 2025
@SergeyMenshykh SergeyMenshykh moved this to Sprint: In Review in Semantic Kernel May 6, 2025
@SergeyMenshykh
SergeyMenshykh enabled auto-merge May 6, 2025 10:19
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue May 6, 2025
Merged via the queue into microsoft:main with commit 3dbfb44 May 6, 2025
@SergeyMenshykh
SergeyMenshykh deleted the add-cancellation-token branch May 6, 2025 10:50
@github-project-automation github-project-automation Bot moved this from Sprint: In Review to Sprint: Done in Semantic Kernel May 6, 2025
Chetan Desh (glorious-beard) pushed a commit to glorious-beard/semantic-kernel that referenced this pull request May 6, 2025
### Motivation, Context and Description

This PR:
1. Propagates the cancellation token from all kernel functions of the
`SessionsPythonPlugin` plugin down to the APIs they call.
2. Refactors the way the plugin adds headers to the request. Instead of
adding them as default headers of the HTTP client, they are now added as
request headers. The result is the same - the headers are sent each call
of any kernel function of the plugin. This change may save time later by
preventing bug troubleshooting if/when an HTTP client is injected into
the plugin and it sets default headers to the client it does not own.
3. Replaces the usage of HTTP client methods for getting content, such
as `ReadAsStringAsync`, with the SK wrappers
`ReadAsStringWithExceptionMappingAsync` to align the plugin's behavior
with that of other SK components.

Contributes to:
microsoft#10070
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
### Motivation, Context and Description

This PR:
1. Propagates the cancellation token from all kernel functions of the
`SessionsPythonPlugin` plugin down to the APIs they call.
2. Refactors the way the plugin adds headers to the request. Instead of
adding them as default headers of the HTTP client, they are now added as
request headers. The result is the same - the headers are sent each call
of any kernel function of the plugin. This change may save time later by
preventing bug troubleshooting if/when an HTTP client is injected into
the plugin and it sets default headers to the client it does not own.
3. Replaces the usage of HTTP client methods for getting content, such
as `ReadAsStringAsync`, with the SK wrappers
`ReadAsStringWithExceptionMappingAsync` to align the plugin's behavior
with that of other SK components.

Contributes to:
microsoft#10070

This branch was previously deployed

1 inactive deployment
integration — f90cfc27 Deployed May 6, 2025 by SergeyMenshykh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants