-
Notifications
You must be signed in to change notification settings - Fork 4.3k
.Net: Add optional role parameter to 'ResponseContentPart' conversion methods #13156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
@microsoft-github-policy-service agree |
@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 |
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 |
There was a problem hiding this 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 addresses issue #13154 by adding role-aware content part conversion to properly differentiate between input and output text content parts based on the author role. The changes ensure that text content from assistant messages is converted to OutputText
parts while other roles create InputText
parts.
- Added optional
AuthorRole? role
parameter toToResponseContentPart
methods inKernelContentExtensions
- Updated text content conversion logic to create
OutputText
parts for assistant role andInputText
parts for others - Modified tests to validate correct content part types based on author role
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
KernelContentExtensions.cs | Added role parameter and logic to create appropriate text content part types |
ChatContentMessageExtensions.cs | Updated to pass author role when converting message items to response content parts |
ChatContentMessageExtensionsTests.cs | Enhanced test validation to check for correct content part types based on role |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
dotnet/src/Agents/OpenAI/Extensions/ChatContentMessageExtensions.cs
Outdated
Show resolved
Hide resolved
…ns.cs Co-authored-by: Copilot <[email protected]>
Motivation and Context
Fix #13154
Description
Introduce an optional
AuthorRole? role
parameter to theToResponseContentPart
methods inKernelContentExtensions
. Update theToResponseItem
method inChatContentMessageExtensions
to utilize this role for determining the correct content part type (Input or Output). Modify tests inChatContentMessageExtensionsTests
to ensure accurate validation of content part types based on the author role.Contribution Checklist