Fix a couple of issues in M.E.AI.OpenAI clients#6827
Merged
stephentoub merged 1 commit intodotnet:mainfrom Sep 24, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes two issues in the Microsoft.Extensions.AI.OpenAI clients: preventing failures when setting AllowMultipleToolCalls without tools, and handling participant names with invalid characters through sanitization.
- Conditionally set AllowMultipleToolCalls only when tools are present to prevent API failures
- Implement author name sanitization to remove invalid characters for OpenAI participant names
- Add comprehensive test coverage for the participant name sanitization functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| OpenAIChatClient.cs | Adds author name sanitization logic and conditional AllowMultipleToolCalls setting |
| OpenAIResponsesChatClient.cs | Moves AllowMultipleToolCalls setting to only apply when tools exist |
| OpenAIConversionTests.cs | Updates tests to verify participant name sanitization behavior |
| CHANGELOG.md | Documents the bug fixes in the release notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
Outdated
Show resolved
Hide resolved
1. Setting AllowMultipleToolCalls if there aren't any tools results in failure. Fix it to only set the property if tools have been added. 2. The chat completion service fails if a participant name containing anything other than a constrained set of characters are included. Fix it with a sanitized value.
f49d03d to
b039725
Compare
eiriktsarpalis
approved these changes
Sep 24, 2025
jeffhandley
pushed a commit
that referenced
this pull request
Sep 24, 2025
1. Setting AllowMultipleToolCalls if there aren't any tools results in failure. Fix it to only set the property if tools have been added. 2. The chat completion service fails if a participant name containing anything other than a constrained set of characters are included. Fix it with a sanitized value.
This was referenced Oct 14, 2025
Closed
Merged
This was referenced Oct 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Microsoft Reviewers: Open in CodeFlow