Skip to content

.NET: Add Run overloads to expose ChatClientAgentRunOptions in IntelliSense#3115

Merged
westey-m merged 6 commits intomainfrom
copilot/improve-chat-client-agent-options
Jan 8, 2026
Merged

.NET: Add Run overloads to expose ChatClientAgentRunOptions in IntelliSense#3115
westey-m merged 6 commits intomainfrom
copilot/improve-chat-client-agent-options

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Motivation and Context

ChatClientAgentRunOptions provides specialized configuration for ChatClientAgent.RunAsync but is not discoverable through IntelliSense. Users must read documentation to learn they can pass it to methods accepting AgentRunOptions.

Related: #521

Description

Added extension methods on ChatClientAgent that explicitly accept ChatClientAgentRunOptions for improved API discoverability.

Implementation:

  • New ChatClientAgentExtensions class with 12 extension methods covering all RunAsync, RunStreamingAsync, and generic RunAsync<T> overloads
  • Each extension method casts ChatClientAgentRunOptions to AgentRunOptions and delegates to existing base methods
  • No behavior changes—existing runtime type checking in ChatClientAgent already handles these options

Before:

// ChatClientAgentRunOptions not visible in IntelliSense
var options = new ChatClientAgentRunOptions(new ChatOptions { Temperature = 0.7f });
await agent.RunAsync("message", thread, options); // options typed as AgentRunOptions

After:

// Dedicated overload shows ChatClientAgentRunOptions in IntelliSense
var options = new ChatClientAgentRunOptions(new ChatOptions { Temperature = 0.7f });
await agent.RunAsync("message", thread, options); // options typed as ChatClientAgentRunOptions

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: Improve ChatClientAgentRunOptions discoverability</issue_title>
<issue_description>Documentation states that ChatClientAgent.RunAsync is able to handle specialized options. These options are currently not discoverable by just using the APIs i.e. browsing through intellisense.

It would be nice to have at least an overload that would accept ChatClientAgentRunOptions so users can find out about them without relying on the docs.

Related: #521 (comment)
https://learn.microsoft.com/en-us/agent-framework/user-guide/agents/running-agents?pivots=programming-language-csharp#agent-run-options

cc @stephentoub @westey-m @TaoChenOSU @rogerbarreto </issue_description>

<agent_instructions>We should add an extension method class for ChatClientAgent that adds an overload for each RunAsync and RunStreamingAsync variation that takes a ChatClientAgentRunOptions instead of an AgentRunOptions parameter.
Check both ChatClientAgent and AIAgent for all the RunAsync and RunStreamingAsync variations.
The new extension methods should just call into the existing methods, since they all already check if the provided options are of type ChatClientAgentRunOptions (which inherits from AgentRunOptions).
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 7, 2026 11:04
…entAgentRunOptions

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copilot AI changed the title [WIP] Add overload for ChatClientAgent.RunAsync to enhance options discoverability Add extension methods to expose ChatClientAgentRunOptions in IntelliSense Jan 7, 2026
Copilot AI requested a review from westey-m January 7, 2026 11:12
@moonbox3 moonbox3 added the .NET label Jan 7, 2026
@github-actions github-actions bot changed the title Add extension methods to expose ChatClientAgentRunOptions in IntelliSense .NET: Add extension methods to expose ChatClientAgentRunOptions in IntelliSense Jan 7, 2026
@westey-m westey-m marked this pull request as ready for review January 7, 2026 11:34
Copilot AI review requested due to automatic review settings January 7, 2026 11:34
Copy link
Contributor

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 extension methods to improve IntelliSense discoverability of ChatClientAgentRunOptions when using ChatClientAgent. Previously, developers had to rely on documentation to know that ChatClientAgentRunOptions could be passed to methods accepting AgentRunOptions.

Key changes:

  • Added ChatClientAgentExtensions class with 12 extension methods accepting ChatClientAgentRunOptions instead of the base AgentRunOptions
  • Each extension method casts the specialized options to the base type and delegates to existing methods
  • Added comprehensive unit tests covering 8 of the 12 extension methods (RunAsync and RunStreamingAsync variants)

Reviewed changes

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

File Description
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentExtensions.cs New extension methods class providing 12 overloads for RunAsync, RunStreamingAsync, and generic RunAsync that explicitly accept ChatClientAgentRunOptions
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentExtensionsTests.cs New test file with unit tests for the extension methods, covering RunAsync and RunStreamingAsync variants but missing tests for the 4 generic RunAsync methods

@westey-m westey-m changed the title .NET: Add extension methods to expose ChatClientAgentRunOptions in IntelliSense .NET: Add Run overloads to expose ChatClientAgentRunOptions in IntelliSense Jan 8, 2026
@westey-m westey-m added this pull request to the merge queue Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Improve ChatClientAgentRunOptions discoverability

6 participants