Skip to content

Support conditional approval from inside AIFunction (trigger approval flow at runtime) #7449

@Vijay-Nirmal

Description

@Vijay-Nirmal

Feature request: Support conditional approval inside AIFunction

Problem:
Currently, using ApprovalRequiredAIFunction in Microsoft.Extensions.AI requires approval every time the function is called, because approval is checked before the function is executed. This does not allow for approval checks that need to be determined by logic inside the function (e.g., only require approval for sensitive arguments).

Proposal:
Add official support for conditional approval, where the function implementation itself can determine (at runtime, based on input) whether approval is required, and trigger the approval flow only in those cases.

Motivation:

  • Enables more flexible, real-world use cases (e.g. operations on sensitive data, approval for write operation based params etc)
  • Reduces friction and avoids unnecessary approvals for low-risk operations
  • Better aligns with user expectations for how function invocation and approval UX should work

Suggested approaches:

  • Add an API or return type that allows the function to indicate approval is required after inspecting the input, pausing execution until user approval is obtained.
  • Alternatively, allow returning a special result to trigger the approval flow from inside the function and pass the approval result as the param if approved for the same funcation call with same params as before

Nice to have

  • Allowing users to edit the param before approving

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librariesuntriaged

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions