-
Notifications
You must be signed in to change notification settings - Fork 849
Allow FunctionResultContent pass-through when CallId matches #7229
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
Co-authored-by: stephentoub <[email protected]>
|
@copilot also unseal FunctionCallContent and FunctionResultContent and add tests validating that an AIFunction can return a FunctionResultContent-derived type and that instance is what's propagated to the IChatClient wrapped by the FunctionInvokingChatClient. |
…e propagation test Co-authored-by: stephentoub <[email protected]>
…nt test Co-authored-by: stephentoub <[email protected]>
Done in 790f979. Unsealed both |
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs
Show resolved
Hide resolved
…ount Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[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.
Otherwise, LGTM.
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs
Outdated
Show resolved
Hide resolved
…onResultContent tests Co-authored-by: jozkee <[email protected]>
FunctionInvokingChatClient.CreateResponseMessagesshould reuseFunctionResultContentreturned by the function if theCallIdmatchesFunctionInvokingChatClient.csat line 1230FunctionCallContentandFunctionResultContentclassesFunctionResultContenttype is propagated to the innerIChatClientSummary
This PR modifies
FunctionInvokingChatClient.CreateResponseMessagesto check if the function result is already aFunctionResultContentwith a matchingCallId. If so, it uses that instance directly instead of wrapping it in a newFunctionResultContent. This gives the AIFunction flexibility to create its own FunctionResultContent configured however it wants.Additionally, this PR unseals
FunctionCallContentandFunctionResultContentclasses to allow derivation.Changes:
FunctionInvokingChatClient.CreateFunctionResultContentmethod to check if the result is aFunctionResultContentwith a matchingCallIdand return it directlyFunctionCallContentandFunctionResultContentclasses to allow derivationFunctionReturningFunctionResultContentWithMatchingCallId_UsesItDirectly: Verifies that when a function returns a FunctionResultContent with matching CallId, it is used directly (same reference)FunctionReturningFunctionResultContentWithMismatchedCallId_WrapsIt: Verifies that when a function returns a FunctionResultContent with mismatched CallId, it is wrapped in a new FunctionResultContent (with the inner one reference-equal)FunctionReturningDerivedFunctionResultContent_PropagatesInstanceToInnerClient: Verifies that a derived FunctionResultContent type is properly propagated to the wrapped IChatClient and is the only one in the tool message (same reference)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Microsoft Reviewers: Open in CodeFlow