-
Notifications
You must be signed in to change notification settings - Fork 849
Unseal FunctionCallContent/FunctionResultContent; make MCP types extend them #7201
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
Co-authored-by: jozkee <[email protected]>
…ew approval types Co-authored-by: jozkee <[email protected]>
Co-authored-by: jozkee <[email protected]>
…ypes Co-authored-by: jozkee <[email protected]>
Co-authored-by: jozkee <[email protected]>
Co-authored-by: jozkee <[email protected]>
jozkee
left a comment
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.
@copilot please fix errors and address feedback.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalRequestContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalResponseContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolResultContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
...ies/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs
Show resolved
Hide resolved
…nts properties, fix idToContentMapping Co-authored-by: jozkee <[email protected]>
Co-authored-by: jozkee <[email protected]>
…Dictionary, use Result instead of Output Co-authored-by: jozkee <[email protected]>
All feedback addressed in commits 598f78b, 23d5d20, and 29454f9. Changes include:
|
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalRequestContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalResponseContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
…ctionaryStringObject Co-authored-by: jozkee <[email protected]>
d3a7a8f to
0f47aa5
Compare
Undo unneeded changes Updated OpenAIResponsesChatClient Updated tests
0f47aa5 to
17daa5c
Compare
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 refactors the MCP (Model Context Protocol) approval types to use a unified approval mechanism by extending the existing FunctionCallContent and FunctionResultContent base types instead of having separate MCP-specific approval types.
Changes:
- Unsealed
FunctionCallContentandFunctionResultContentto allow inheritance - Made
McpServerToolCallContentandMcpServerToolResultContentextend the unsealed base types - Removed
McpServerToolApprovalRequestContentandMcpServerToolApprovalResponseContent, using the unifiedFunctionApprovalRequestContent/FunctionApprovalResponseContentinstead - Changed
ArgumentsfromIReadOnlyDictionary<string, object?>toIDictionary<string, object?>for mutability - Renamed
Outputproperty toResultinMcpServerToolResultContentto align with base class
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
FunctionCallContent.cs |
Unsealed class to allow inheritance |
FunctionResultContent.cs |
Unsealed class to allow inheritance |
McpServerToolCallContent.cs |
Now extends FunctionCallContent, exposing ToolName as alias for Name |
McpServerToolResultContent.cs |
Now extends FunctionResultContent |
McpServerToolApprovalRequestContent.cs |
Deleted - replaced by FunctionApprovalRequestContent |
McpServerToolApprovalResponseContent.cs |
Deleted - replaced by FunctionApprovalResponseContent |
FunctionInvokingChatClient.cs |
Added pattern matching to exclude McpServerToolCallContent from local approval processing; fixed spelling error |
OpenAIResponsesChatClient.cs |
Updated to use unified approval types; adjusted serialization for IDictionary |
CompatibilitySuppressions.xml |
Added suppressions for breaking changes |
| Test files | Updated tests to use unified approval types; added comprehensive mixed-scenario tests |
|
I'm unclear how this is intended to work. If a service sends an MCP call content, how does the client know it's not supposed to try to invoke something for it? Is this based on the premise that an FCC has an InvocationRequired property? Or is it based on the premise that FCCs that come with a paired FRC are implicitly considered not requiring invocation, in which case case what happens if the server sends the MCP call in one response and either doesn't have result content or sends it in a separate response? Also, the FICC is being modified here to explicitly rule out some FCC-derived types. It doesn't scale for FICC to have to know about every FCC-derived type that should be ignored. |
Address Review Feedback - All Comments Resolved ✅
All new review comments have been addressed:
Documentation Changes
Constructor Changes
arguments: nullparameter from base constructor callJSON Serialization Changes
✅ Changed all deserializations from
IReadOnlyDictionaryStringObjecttoIDictionaryStringObject:✅ Changed all serializations to use
IDictionaryStringObject:FunctionInvokingChatClient Changes
All changes maintain the breaking changes we accepted (using
IDictionaryinstead ofIReadOnlyDictionary) while simplifying the code.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Microsoft Reviewers: Open in CodeFlow