Skip to content

GetResponseClient #7288

@ahmadMahfoud

Description

@ahmadMahfoud

Description

tools calling when using and GetResponseClient() cause the the error :
System.ClientModel.ClientResultException HResult=0x80131500 Message=Service request failed. Status: 400 (Bad Request)

Source=OpenAI StackTrace: at OpenAI.ClientPipelineExtensions.d__0.MoveNext() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable2.MoveNext() at Microsoft.Agents.AI.ChatClientAgent.d__27`2.MoveNext() at AssistantAPI.Infrastructure.Agents.AssistantAgentService.d__11.MoveNext() in G:\Ahmed\Claude\AssistantAPI.Infrastructure\Agents\AssistantAgentService.cs:line 295

This exception was originally thrown at this call stack: OpenAI.ClientPipelineExtensions.ProcessMessageAsync(System.ClientModel.Primitives.ClientPipeline, System.ClientModel.Primitives.PipelineMessage, System.ClientModel.Primitives.RequestOptions) System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() in ConfiguredValueTaskAwaitable.cs OpenAI.Responses.ResponsesClient.CreateResponseAsync(System.ClientModel.BinaryContent, System.ClientModel.Primitives.RequestOptions) Microsoft.Extensions.AI.OpenAIResponsesChatClient.GetResponseAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken) Microsoft.Extensions.AI.FunctionInvokingChatClient.GetResponseAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken) Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync<TAgentResponse, TChatClientResponse>(System.Func<Microsoft.Extensions.AI.IChatClient, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken, System.Threading.Tasks.Task>, System.Func<TChatClientResponse, TAgentResponse>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.AgentRunOptions, System.Threading.CancellationToken) Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync<TAgentResponse, TChatClientResponse>(System.Func<Microsoft.Extensions.AI.IChatClient, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken, System.Threading.Tasks.Task>, System.Func<TChatClientResponse, TAgentResponse>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.AgentRunOptions, System.Threading.CancellationToken) AssistantAPI.Infrastructure.Agents.AssistantAgentService.RunAgentLoopAsync(AssistantAPI.Core.Entities.AgentsEntities.Run, Microsoft.Agents.AI.AIAgent, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, System.Collections.Generic.List<Microsoft.Extensions.AI.AITool>) , while if using GetChatCleint it works fime

Reproduction Steps

creating ResponseClient and use it tools causes api error in the response.

Expected behavior

it should call the tools and finish the response.

Actual behavior

System.ClientModel.ClientResultException HResult=0x80131500 Message=Service request failed. Status: 400 (Bad Request)

Source=OpenAI StackTrace: at OpenAI.ClientPipelineExtensions.d__0.MoveNext() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable2.MoveNext() at Microsoft.Agents.AI.ChatClientAgent.d__27`2.MoveNext() at AssistantAPI.Infrastructure.Agents.AssistantAgentService.d__11.MoveNext() in G:\Ahmed\Claude\AssistantAPI.Infrastructure\Agents\AssistantAgentService.cs:line 295

This exception was originally thrown at this call stack: OpenAI.ClientPipelineExtensions.ProcessMessageAsync(System.ClientModel.Primitives.ClientPipeline, System.ClientModel.Primitives.PipelineMessage, System.ClientModel.Primitives.RequestOptions) System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() in ConfiguredValueTaskAwaitable.cs OpenAI.Responses.ResponsesClient.CreateResponseAsync(System.ClientModel.BinaryContent, System.ClientModel.Primitives.RequestOptions) Microsoft.Extensions.AI.OpenAIResponsesChatClient.GetResponseAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken) Microsoft.Extensions.AI.FunctionInvokingChatClient.GetResponseAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken) Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync<TAgentResponse, TChatClientResponse>(System.Func<Microsoft.Extensions.AI.IChatClient, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken, System.Threading.Tasks.Task>, System.Func<TChatClientResponse, TAgentResponse>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.AgentRunOptions, System.Threading.CancellationToken) Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync<TAgentResponse, TChatClientResponse>(System.Func<Microsoft.Extensions.AI.IChatClient, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Extensions.AI.ChatOptions, System.Threading.CancellationToken, System.Threading.Tasks.Task>, System.Func<TChatClientResponse, TAgentResponse>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>, Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.AgentRunOptions, System.Threading.CancellationToken) AssistantAPI.Infrastructure.Agents.AssistantAgentService.RunAgentLoopAsync(AssistantAPI.Core.Entities.AgentsEntities.Run, Microsoft.Agents.AI.AIAgent, System.Collections.Generic.List<Microsoft.Extensions.AI.ChatMessage>, System.Collections.Generic.List<Microsoft.Extensions.AI.AITool>)

Regression?

No response

Known Workarounds

use GetChatClient instead of GetResponseClient()

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librariesuntriagedwaiting-author-feedback 📭The author of this issue needs to respond in order for us to continue investigating this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions