Skip to content

.Net: Bug: OpenAIResponseAgent Throws 400 Error When Assistant Message Is Included in Chat History #13154

@renjithpaul-hrb

Description

@renjithpaul-hrb

Describe the bug
When running the test from the SK repo https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/OpenAIResponse/Step02_OpenAIResponseAgent_ConversationState.cs, the application throws a ClientResultException due to an invalid value in the request payload when an Assistant message is included in the chat history.

 GettingStarted.OpenAIResponseAgents.Step02_OpenAIResponseAgent_ConversationState.ManuallyConstructPastConversationAsync
 Duration: 9.7 sec

Message: 
System.ClientModel.ClientResultException : HTTP 400 (invalid_request_error: invalid_value)
Parameter: input[1].content[0]

Invalid value: 'input_text'. Supported values are: 'output_text' and 'refusal'.

Stack Trace: 
ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
OpenAIResponseClient.CreateResponseAsync(BinaryContent content, RequestOptions options)
OpenAIResponseClient.CreateResponseAsync(IEnumerable1 inputItems, ResponseCreationOptions options, CancellationToken cancellationToken) ResponseThreadActions.InvokeAsync(OpenAIResponseAgent agent, ChatHistory history, AgentThread agentThread, AgentInvokeOptions options, CancellationToken cancellationToken)+MoveNext() line 48 Boolean>.GetResult() OpenAIResponseAgent.InvokeAsync(ICollection1 messages, AgentThread thread, AgentInvokeOptions options, CancellationToken cancellationToken)+MoveNext() line 62
OpenAIResponseAgent.InvokeAsync(ICollection`1 messages, AgentThread thread, AgentInvokeOptions options, CancellationToken cancellationToken)+MoveNext() line 62
Boolean>.GetResult()
Step02_OpenAIResponseAgent_ConversationState.ManuallyConstructPastConversationAsync() line 39
Step02_OpenAIResponseAgent_ConversationState.ManuallyConstructPastConversationAsync() line 39
--- End of stack trace from previous location ---

Standard Output: 

# user: knock knock.

# assistant: Who's there?

# user: Orange.

To Reproduce
 Steps to reproduce the behavior:

Clone the Semantic Kernel repo from GitHub.
Navigate to dotnet/samples/GettingStartedWithAgents/OpenAIResponse/.
Open and run Step02_OpenAIResponseAgent_ConversationState.cs.
Ensure the chat history includes an Assistant message with input_text as the content type.
Observe the error thrown during execution.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

Image

Platform

Language: C#
Source: GitHub main branch of Semantic Kernel repo
AI model: OpenAI:GPT-4.1
IDE: Visual Studio
OS: Windows

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codebugSomething isn't workingtriage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions