.NET: Fix FunctionInvocationDelegatingAgent to preserve all AgentRunOptions properties (#4179)

When converting base AgentRunOptions to ChatClientAgentRunOptions, the middleware
now preserves AllowBackgroundResponses, ContinuationToken, and AdditionalProperties
in addition to ResponseFormat.

Added unit test verifying all properties are preserved during the conversion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
SergeyMenshykh
2026-02-23 16:37:43 +00:00
committed by GitHub
co-authored by Copilot
parent ba454552c5
commit 892c177e93
2 changed files with 61 additions and 1 deletions
@@ -32,7 +32,13 @@ internal sealed class FunctionInvocationDelegatingAgent : DelegatingAIAgent
{
if (options is null || options.GetType() == typeof(AgentRunOptions))
{
options = new ChatClientAgentRunOptions();
options = new ChatClientAgentRunOptions()
{
ResponseFormat = options?.ResponseFormat,
AllowBackgroundResponses = options?.AllowBackgroundResponses,
ContinuationToken = options?.ContinuationToken,
AdditionalProperties = options?.AdditionalProperties,
};
}
if (options is not ChatClientAgentRunOptions aco)