Skip to content

Conversation

westey-m
Copy link
Contributor

@westey-m westey-m commented Aug 26, 2025

  • Adding an ApprovalRequiredAIFunction that can be used to decorate an AIFunction
  • Adding UserInputRequestContent and UserInputResponseContent base types to represent all user input
  • Adding FunctionApprovalRequestContent and FunctionApprovalResponseContent for function approvals
  • Updated FunctionInvokingChatClient with approval generation hand handling.
Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI review requested due to automatic review settings August 26, 2025 08:22
@westey-m westey-m requested a review from a team as a code owner August 26, 2025 08:22
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Aug 26, 2025
@westey-m
Copy link
Contributor Author

@dotnet-policy-service agree company="Microsoft"

Copy link
Contributor

@Copilot Copilot AI left a 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 pull request adds comprehensive function approval support to the Microsoft.Extensions.AI library. The changes enable functions to require user approval before execution, providing a mechanism for human oversight of AI function calls.

  • Introduces ApprovalRequiredAIFunction wrapper to mark functions requiring approval
  • Adds user input content base types and function approval request/response content types
  • Updates FunctionInvokingChatClient to handle approval workflows for both regular and streaming scenarios

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ApprovalRequiredAIFunction.cs Core wrapper class for functions requiring approval with customizable approval callback
UserInputRequestContent.cs & UserInputResponseContent.cs Base types for user input request/response patterns
FunctionApprovalRequestContent.cs & FunctionApprovalResponseContent.cs Specific content types for function approval workflows
FunctionInvokingChatClient.cs Major updates to handle approval processing, request/response conversion, and streaming approval handling
Test files Comprehensive test coverage for new approval functionality including edge cases and streaming scenarios
AssertExtensions.cs Refactored message comparison logic into reusable helper method
Comments suppressed due to low confidence (2)

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs:1

  • The parameter description is incomplete. It should describe what originalMessages contains, such as 'The list of chat messages to process for approval requests and responses.'
// Licensed to the .NET Foundation under one or more agreements.

test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs:1

  • Typo in method name: 'FunctionCalsAreBuffered' should be 'FunctionCallsAreBuffered'.
// Licensed to the .NET Foundation under one or more agreements.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware of #6695.

@stephentoub stephentoub force-pushed the add-approvals-to-functioninvokingchatclient branch from 9c554ac to ae3e24b Compare September 5, 2025 00:57
@stephentoub stephentoub self-assigned this Sep 5, 2025
@stephentoub
Copy link
Member

I'm working on this now to get this merged today...

@stephentoub stephentoub force-pushed the add-approvals-to-functioninvokingchatclient branch 2 times, most recently from 2fbb35d to 6969e3e Compare September 5, 2025 22:00
@stephentoub stephentoub requested review from a team as code owners September 5, 2025 22:00
@stephentoub stephentoub force-pushed the add-approvals-to-functioninvokingchatclient branch from 6969e3e to c0d0996 Compare September 5, 2025 22:01
@stephentoub stephentoub enabled auto-merge (squash) September 5, 2025 22:02
@stephentoub stephentoub merged commit bc12dd0 into dotnet:main Sep 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants