-
Notifications
You must be signed in to change notification settings - Fork 924
.NET: fix forwarding conversationId to IChatClient in OpenAI Responses #2632
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
Conversation
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AIAgentResponseExecutor.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/HostedAgentResponseExecutor.cs
Show resolved
Hide resolved
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 an issue where the client's conversationId was incorrectly being forwarded to the underlying IChatClient via ChatOptions.ConversationId. The fix ensures that conversation management remains at the hosting layer level and is not passed down to the chat client, which may have its own conversation handling or none at all.
Key changes:
- Removed forwarding of
ConversationIdfrom request toChatOptionsin response executors - Added comprehensive tests to verify the fix works for both streaming and non-streaming scenarios
- Enhanced test infrastructure to track
ChatOptionspassed to mock chat clients
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AIAgentResponseExecutor.cs | Removed ConversationId assignment to ChatOptions with explanatory comment |
| dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/HostedAgentResponseExecutor.cs | Removed ConversationId assignment to ChatOptions with explanatory comment |
| dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/TestHelpers.cs | Added LastChatOptions property to SimpleMockChatClient for test verification |
| dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/OpenAIResponsesIntegrationTests.cs | Added two integration tests and helper methods to verify conversationId is not forwarded to IChatClient |
In #2477 the problem was raised: client's conversationId does not map to what
IChatClientexpects in the options.We should not forward the client's conversationId into
IChatClient.Contribution Checklist