Skip to content

Conversation

rogerbarreto
Copy link
Contributor

@rogerbarreto rogerbarreto commented Sep 23, 2025

Contributing to the Azure SDK

Note

This doesn't change current existing public surface.

Today, if you're using the convenience types and you just want to set a user-agent header on a request (you're handed the instance and thus can't configure it at creation), the only supported option I see is to abandon the convenience methods and adopt the protocol methods, which some of those methods are internal as well as most of the types used for those are also internal which means formatting all the input JSON and parsing all the responses. That's a big pill to swallow.

Based on need, could we add a few convenience overloads that just take a RequestContext instead of a CancellationToken?. It results in minimal additional surface area with almost no additional duplicated code, as it's just taking a RequestContext instead of taking a CancellationToken and calling ToRequestContext on it.

I've demonstrated in this PR with methods used by PersistentAgentChatClient implementation internals, as well as other methods that are important for AgentCreation in the upcoming agent framework.

Similar to this OpenAI SDK update:

Additional changes

CC: @stephentoub

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds internal method overloads that accept RequestContext instead of CancellationToken to provide more flexibility for configuring requests without abandoning convenience methods. The changes enable setting custom headers (like user-agent) on requests while maintaining the existing public surface.

Key changes:

  • Replaces FromCancellationToken() calls with ToRequestContext() extension method
  • Adds internal method overloads accepting RequestContext parameters
  • Implements user-agent header injection for MEAI implementation

Reviewed Changes

Copilot reviewed 7 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
CancellationTokenExtensions.cs New extension method to convert CancellationToken to RequestContext
PersistentAgentsChatClient.cs Adds user-agent policy and converts method calls to use RequestContext
ThreadRuns.cs Adds internal GetRunsAsync overload and converts to use extension method
ThreadRuns.Streaming.cs Adds internal streaming method overloads and converts method calls
PersistentAgentsFiles.cs Converts file upload methods to use extension method
PersistentAgentsAdministrationClient.cs Removes obsolete protocol method documentation
PersistentAgentsChatClientTests.cs Minor whitespace cleanup

@SergeyMenshykh SergeyMenshykh self-assigned this Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants