Skip to content

Conversation

HillPhelmuth
Copy link

@HillPhelmuth HillPhelmuth commented Sep 20, 2025

Motivation and Context

Fix #13154

Description

Introduce an optional AuthorRole? role parameter to the ToResponseContentPart methods in KernelContentExtensions . Update the ToResponseItem method in ChatContentMessageExtensions to utilize this role for determining the correct content part type (Input or Output). Modify tests in ChatContentMessageExtensionsTests to ensure accurate validation of content part types based on the author role.

Contribution Checklist

Introduce an optional `AuthorRole? role` parameter to the `ToResponseContentPart` methods in `KernelContentExtensions` . Update the `ToResponseItem` method in `ChatContentMessageExtensions` to utilize this role for determining the correct content part type (Input or Output). Modify tests in `ChatContentMessageExtensionsTests` to ensure accurate validation of content part types based on the author role.
@HillPhelmuth HillPhelmuth requested review from Copilot and removed request for Copilot September 20, 2025 01:28
@HillPhelmuth HillPhelmuth requested a review from a team as a code owner September 20, 2025 01:28
@moonbox3 moonbox3 added the .NET Issue or Pull requests regarding .NET code label Sep 20, 2025
@github-actions github-actions bot changed the title Add optional role parameter to 'ResponseContentPart' conversion methods .Net: Add optional role parameter to 'ResponseContentPart' conversion methods Sep 20, 2025
@HillPhelmuth
Copy link
Author

HillPhelmuth commented Sep 20, 2025

@microsoft-github-policy-service agree

@wim-gdwi
Copy link

@HillPhelmuth do you have any clue when the merge will be completed, and/or do you have a workaround for this issue perhaps? I'm currently completely blocked by this issue since I need to use the responses API but can never build up a reasonable conversation...

@HillPhelmuth
Copy link
Author

@HillPhelmuth do you have any clue when the merge will be completed, and/or do you have a workaround for this issue perhaps? I'm currently completely blocked by this issue since I need to use the responses API but can never build up a reasonable conversation...

I have no idea when, or even if, it will be merged. It seems that development on this project has slowed down quite a bit over the last month or two, so I don't have a good sense of when this issue and associated PR will be on the SK team's radar. Hopefully the pace picks back up after .NET 10 is released.

There's a fairly straightforward work-around though. The OpenAI Responses api is designed to be stateful, so you can pass the responseId and it will use the stored history. Example is in ManageConversationStateWithResponseIdAsync() (important note: this example uses the agent thread instead of stored history, but it will work by setting StoreEnabled = true instead when instantiating your OpenAIResponseAgent). This way you don't have to send the broken assistant messages when invoking the agent. This also has the benefit of being OpenAI's recommended approach.

@wim-gdwi
Copy link

The problem with your workaround is that it only works from "scratch". if you reload an agent with previous history, or with history coming from another agent to start with (which is the case in our multi agentic framework using SK), then the trick of enabling the store doesn't really work. Hope the SK guys come wit ha solution really soon or I'm going to have to implement OpenAI directly for response API... which kind of defeats the purpose of SK all together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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