Skip to content

[Microsoft.Extensions.AI] Add ToolApprovalRequestContent.IsInvokerRequested #7550

Closed

Description

@javiercn

Summary

Microsoft.Extensions.AI.ToolApprovalRequestContent gains a new IsInvokerRequested property so consumers (UIs, policy layers, telemetry) can distinguish approval requests that exist because the underlying function is an ApprovalRequiredAIFunction from approval requests that an invoker (typically FunctionInvokingChatClient, "FICC") added as collateral because a peer call in the same response required approval. This is the only information needed to render an approval prompt only for the calls that genuinely demanded one, while silently auto-approving the collateral peers — a workflow that has no general solution today once FICC is wrapped behind additional IChatClient layers.

Draft implementation: #7549.

Motivation

FunctionInvokingChatClient enforces an important invariant: if any function call in a single assistant response targets an ApprovalRequiredAIFunction, all function calls in that response are converted into ToolApprovalRequestContent items before being yielded to the next layer. This is required so approvals and rejections stay coherent across the batch — the client cannot partially execute some calls while waiting on approval for others without losing the ability to correctly attribute results.

The consequence is that downstream consumers (in particular UI layers that render approval prompts) receive a mixed bag of ToolApprovalRequestContent items where some correspond to functions the application explicitly marked as approval-required and others are pure collateral. Today there is no way to tell which is which from the content itself.

In principle a consumer could re-resolve the tool by name against ChatOptions.Tools/AdditionalTools and check tool.GetService<ApprovalRequiredAIFunction>(), but in practice this does not work for any non-trivial pipeline:

  • FICC is commonly wrapped by additional DelegatingChatClient layers (telemetry, caching, evaluation, OpenTelemetry, retry, governance, an IChatClient exposed by an agent framework, etc.). The UI sits at the top of the pipeline and has no guaranteed handle on the specific tool list FICC saw.
  • The tool list can be mutated by tools themselves during the invocation loop, so what the UI inspects later may not match what FICC saw at the moment of wrapping.
  • Function names are not guaranteed unique, and the matching logic (which mirrors FICC's own FindTool) would have to be reimplemented and kept in sync.
  • For UI scenarios that hydrate ChatMessage instances from persistence, the originating tools may not be available at all.

FICC, by contrast, does know the answer at the exact moment it wraps each call. Exposing that decision on the resulting ToolApprovalRequestContent lets every downstream consumer behave correctly without re-implementing FICC's resolution logic.

Goals

  • Make it trivial for any consumer of ToolApprovalRequestContent — UI components, policy layers, loggers, evaluators — to tell, per request, whether the underlying tool itself required approval or the request was wrapped as collateral by an invoker.
  • Enable UIs to prompt the user only for genuinely approval-required calls and auto-approve the collateral ones, without inspecting ChatOptions.Tools or AdditionalTools.
  • Preserve the existing batch-coherence behavior of FunctionInvokingChatClient: approvals and rejections in a response still flow as a single coordinated batch; the new signal is purely informational.
  • Work uniformly across the non-streaming and streaming code paths.
  • Survive serialization, so the distinction is preserved when conversation history is persisted and rehydrated.
  • Remain robust when an ApprovalRequiredAIFunction is nested inside additional DelegatingAIFunction wrappers.

Non-goals

  • Not a new declarative mechanism for marking functions as approval-required. ApprovalRequiredAIFunction remains the way to opt a function in to approval.
  • Not a change in batching behavior. FICC continues to wrap every concurrent function call in a response when any one of them requires approval. The new property only labels each resulting request; it does not let some calls in a batch be executed while others wait.
  • Not a per-call dynamic approval predicate. The property describes a static fact about the tool the call targets at the moment of wrapping, not "should this specific arguments combination require approval".
  • Not a change to FunctionCallContent. The asymmetry between "tool required approval" and "invoker wrapped a peer" is a property of the approval request envelope, not the underlying call.
  • Not a generalized ToolApprovalRequestSource taxonomy. A future enum (policy-based, MCP-server-declared, etc.) could subsume the boolean, but introducing one is out of scope for this proposal.

Detailed design

New API

Microsoft.Extensions.AI.Abstractions adds a single member to the existing ToolApprovalRequestContent class:

public sealed class ToolApprovalRequestContent : InputRequestContent
{
    // ... existing members unchanged ...

    /// <summary>
    /// Gets or sets a value indicating whether this approval request was added by the invoker
    /// of the tool call rather than because the underlying tool itself was declared as
    /// requiring approval.
    /// </summary>
    /// <remarks>
    /// Defaults to <see langword="false"/>, meaning the underlying tool itself required
    /// approval (for example, the targeted function was an <see cref="ApprovalRequiredAIFunction"/>).
    /// Set to <see langword="true"/> when the invoker (such as
    /// <see cref="FunctionInvokingChatClient"/>) wrapped a peer call as collateral so that
    /// approvals and rejections stay coherent across a batch in which at least one peer
    /// genuinely required approval.
    /// </remarks>
    public bool IsInvokerRequested { get; set; }
}

The property is a mutable, serialized boolean — same shape as FunctionCallContent.InformationalOnly — and is introduced under the existing MEAI001 experimental diagnostic that already covers the approval feature.

Polarity and default

  • false (default) means "the targeted function itself requires approval". This is the safe default for any non-FICC producer that constructs a ToolApprovalRequestContent directly because the tool genuinely demands approval — the property is correct without any code change at the construction site.
  • true means "an invoker added this request as collateral". The targeted function did not itself require approval; the request exists only to keep the batch coherent. Consumers may treat such requests as candidates for auto-approval.

The affirmative direction matches the role FICC plays in the pipeline: the request was invoker-requested, as opposed to function-requested.

Producer behavior (FunctionInvokingChatClient)

FICC sets the flag at both points where it converts FunctionCallContent into ToolApprovalRequestContent:

  1. The non-streaming response path, where FICC walks the assembled messages and rewrites function calls into approval requests when any peer requires approval.
  2. The streaming response path, where FICC buffers updates until it knows whether the batch contains an approval-required call and then flushes a corrected sequence of updates.

Both paths use the same per-call resolution that FICC already performs to drive batch wrapping: look up the function by name across ChatOptions.Tools and AdditionalTools, then ask tool.GetService<ApprovalRequiredAIFunction>(). Using GetService rather than a direct type test is important because it walks DelegatingAIFunction chains; a tool declared as Telemetry(Logging(ApprovalRequired(realFn))) must still be classified as approval-required.

IsInvokerRequested is set to true exactly when this resolution returns null for the call being wrapped — i.e. when no ApprovalRequiredAIFunction is visible behind the targeted function. Otherwise it remains false.

Consumer behavior

Consumers that want today's behavior (treat every ToolApprovalRequestContent as something the user must approve) need no changes. Consumers that want to opt into the new behavior — auto-approving collateral requests while only prompting for the genuine ones — can do so based on the flag alone:

foreach (var request in message.Contents.OfType<ToolApprovalRequestContent>())
{
    if (request.IsInvokerRequested)
    {
        // Collateral: auto-approve without prompting.
        responses.Add(request.CreateResponse(approved: true));
    }
    else
    {
        // Genuine: surface the approval prompt in the UI.
        pendingPrompts.Add(request);
    }
}

This works regardless of how many IChatClient layers sit between the consumer and FICC, and without the consumer needing to inspect, replicate, or even have access to ChatOptions.Tools or AdditionalTools.

Persistence

IsInvokerRequested is a regular serialized property: it round-trips through System.Text.Json using AIJsonUtilities.DefaultOptions the same way the rest of ToolApprovalRequestContent does. Conversation histories that include approval requests preserve the distinction across persist/rehydrate cycles, so UIs that re-render an existing thread continue to make the right decision for previously-recorded requests.

Interaction with non-function tool calls

FICC only constructs ToolApprovalRequestContent for FunctionCallContent. Approval requests for other tool call kinds (for example MCP server tool calls produced by an upstream service) are passed through unchanged; their IsInvokerRequested retains whatever value the producer set, which by default is false. This matches the polarity contract: a ToolApprovalRequestContent that arrives from outside FICC is, by definition, not invoker-added by FICC.

Activity

  1. javiercn commented on Jun 9, 2026

    @javiercn
    MemberAuthor

    @jozkee I spoke with @halter73 and he mentioned that you would be the person to talk about this. What's the best channel to bring this proposal forward?

  2. jozkee commented on Jun 9, 2026

    @jozkee
    Member

    What's the best channel to bring this proposal forward?

    This is the right channel. cc @westey-m

    Would you be open to alternatively have a delegate in FICC, say ApprovalInvoker (similar to FunctionInvoker), so FICC can resolve approvals inline without yielding approval requests back to the caller? This would also sidestep the collateral function call problem entirely.

  3. added
    area-ai
    on Jun 9, 2026
  4. javiercn commented on Jun 9, 2026

    @javiercn
    MemberAuthor

    @jozkee that only works when everything can be resolved within the same process without finishing the current turn. If my UI lives in another layer, I can't just wire up a delegate and hold on to the execution in memory until the user acts on the UI.

    There are also situations in which I am not the one wiring up the FICC and don't have access to it.

  5. rpelevin commented on Jun 9, 2026

    @rpelevin

    The delegate option seems useful for same-process approval, but I would still keep the provenance bit on the approval request envelope.

    The hard cases in the issue are exactly the ones where an inline delegate is not enough:

    • the approval UI lives above several IChatClient wrappers;
    • the approval prompt is serialized and rendered after hydration;
    • the user decision arrives in a later turn or from a different process;
    • the caller did not construct the FICC instance and cannot wire the delegate.

    For those cases, the request object itself needs to carry why it exists. Otherwise the UI has to reverse-engineer FICC's tool resolution after the fact, which is the part the proposal is trying to avoid.

    Tests I would want around IsInvokerRequested:

    1. mixed batch with one genuine ApprovalRequiredAIFunction and one collateral peer: genuine request has false, collateral request has true.
    2. nested DelegatingAIFunction around ApprovalRequiredAIFunction is still treated as genuine.
    3. streaming and non-streaming paths produce the same flag values.
    4. serialized and rehydrated ChatMessage preserves the flag.
    5. a UI can auto-approve only collateral requests without access to ChatOptions.Tools.
    6. approval requests produced outside FICC, including future MCP/provider-originated requests, default to genuine unless the producer explicitly says otherwise.

    I would also avoid making the flag imply "safe to execute" by itself. It is provenance, not policy. A policy layer can still decide that a collateral peer should be shown or denied, but it should not have to rediscover whether the request came from the targeted function or from FICC's batch-coherence wrapper.

  6. westey-m commented on Jun 9, 2026

    @westey-m
    Contributor

    If you are using Agent Framework we have introduced an IChatClient decorator that helps address this issue.

    Since the chat client stack is stateless and can be reused by many callers at the same time, FICC doesn't have anywhere to store the tool calls that don't require approval while approval is sought for those that do.

    Agent Framework is stateful though. Specifically, all ChatClient calls run in the context of an agent run, which has a session available. Sessions are used to store state across requests. We can therefore have an Agent Framework Session aware ChatClient decorator that stores these tool calls in the session until the next run. This can be enabled via a single bool setting on ChatClientAgentOptions (EnableNonApprovalRequiredFunctionBypassing) or via adding the custom ChatClient decorator yourself if building your own stack. Of course, the decorator will only work in the context of an AF agent run.

    See https://github.com/microsoft/agent-framework/pull/4950

    On the proposal of adding IsInvokerRequested. Comparing the set of tools decorated with ApprovalRequiredAIFunction with the set of function call content isn't terribly complex. In my opinion there is probably more value from doing something like what we are doing in AF, where the complexity is completely hidden from users, but that can only be done at a higher level in a stateful stack.

  7. javiercn commented on Jun 9, 2026

    @javiercn
    MemberAuthor

    Thanks @westey-m.

    A few thoughts on why the property on the envelope is still the right vehicle, separate from any specific stateful-decorator solution:

    1. The proposal targets every consumer above FICC, not just one stateful one. UI components rendering an approval prompt, policy layers, telemetry/evaluator exporters, governance filters, archival/replay viewers, and history-rehydration code paths all need the same answer to the same question — "did the targeted function require approval, or did FICC add this as collateral?". A stateful pipeline decorator solves it for one specific kind of host; a property on the envelope solves it for every reader of the content.

    2. "Compare the function calls to the set of approval-required tools" is the very workaround the proposal exists to remove. The issue body enumerates why this lookup is impractical at the consumer layer:

    • The consumer typically sits behind one or more DelegatingChatClient wrappers and has no guaranteed handle on the exact ChatOptions.Tools/AdditionalTools FICC saw.
    • Tools can be mutated by tools themselves inside the invocation loop, so the snapshot a consumer inspects after-the-fact may not match what FICC saw at wrap time.
    • Function names aren't guaranteed unique, so the matching logic has to mirror FICC's FindTool exactly and be kept in sync forever.
    • For consumers that rehydrate ChatMessage from persistence, the originating tools may not be available at all.

    FICC already does this resolution once, authoritatively, at the moment of wrapping. Re-doing it at every consumer site — correctly, under wrapping/mutation/rehydration — is exactly the work the proposal is asking to avoid.

    3. Statefulness shouldn't be a prerequisite for getting the right answer. Several legitimate consumer shapes have no session and shouldn't need one to compute a boolean:

    • An approval surface running in a different process that only ever sees the materialized ChatMessage. There is no live pipeline to wrap.
    • A trace exporter that wants to tag spans with whether an approval is genuine or collateral. It's an observer; instantiating a stateful session is the wrong layering.
    • An archived conversation re-rendered in a later viewer. Whatever FICC knew at wrap time is what the viewer needs now, and the only place that survives is the content envelope.

    A stateful-decorator approach is appropriate when there is a stateful host; it doesn't generalize across the consumer surface this proposal targets.

    4. The flag is provenance, not policy. It labels each request with where it came from; it doesn't dictate behavior. A UI can use it to decide what to prompt for. A governance layer can use it to enforce that collateral calls go through a different code path than genuine approvals. A telemetry pipeline can use it as a span attribute. All of those consumers work off the same single boolean.

    5. The flag simplifies any in-pipeline decorator that wants the same distinction. A decorator that today scans options?.Tools ∪ ficc?.AdditionalTools and matches each ToolApprovalRequestContent.ToolCall.Name reduces to request.IsInvokerRequested — fewer moving parts, no risk of skew when a downstream DelegatingAIFunction reorders wrapping, no reflection back into the pipeline.

  8. rpelevin commented on Jun 9, 2026

    @rpelevin

    This framing lands for me.

    The way I would describe the boundary is: a stateful decorator can be an execution optimization, but the envelope property is the durable provenance record.

    Those solve different problems. The decorator can decide what to do in one host/run/session. IsInvokerRequested lets every later reader understand why this approval request exists, even after the live pipeline is gone.

    That matters for:

    • UI prompts that render from persisted ChatMessage;
    • policy layers that run above FICC and do not own the tool list;
    • trace/eval/export pipelines that need to distinguish genuine approval from collateral wrapping;
    • replay viewers that need to explain why a user was or was not prompted.

    So I would treat the API as intentionally small, but not only a UI convenience. It is the bit that prevents approval provenance from being trapped inside one stateful execution path.

    One acceptance test I would add to the list is an archive/replay case: persist a mixed genuine/collateral approval batch, rehydrate it without the original ChatOptions.Tools, and verify the viewer can still classify which requests were function-requested versus invoker-requested from the envelope alone.

    That keeps the higher-level AF decorator useful where available while preserving the lower-level invariant for every consumer of the content.

  9. jozkee commented on Jun 9, 2026

    @jozkee
    Member

    @javiercn I agree a flag at object creation is needed to distinguish between genuine or collateral requests to cover all vectors (ConversationId scenarios not tracking history, Serialization roundtripping, etc).

    I'm still thinking about the name though. ToolApprovalRequestContent lives in MEAI.Abstractions, while FunctionInvokingChatClient is in MEAI. The name IsInvokerRequested feels like it bleeds FICC's vocabulary ("invoker") into the Abstractions layer.

    We could also use an additional property instead, but we would lose the strong typing.

    Aside from that, the proposal is sound to me.

  10. rpelevin commented on Jun 9, 2026

    @rpelevin

    That naming concern makes sense to me.

    At the Abstractions layer, I would name the durable fact a consumer needs, not the producer that happened to create it.

    The fact is not really "FICC requested this." It is:

    • the targeted tool itself required approval; or
    • this approval request exists as collateral because a peer in the same batch required approval.

    If the shape stays boolean, IsCollateralRequest feels cleaner to me than IsInvokerRequested:

    • default false: the targeted tool itself required approval;
    • true: this is a collateral approval request created to preserve batch coherence.

    If you want the extra future-proofing while keeping strong typing, an enum also seems reasonable: ToolApprovalRequestOrigin with ToolDeclared = 0 and BatchCollateral = 1. Then ToolApprovalRequestContent.Origin defaults to ToolDeclared, which preserves the safe behavior for non-FICC producers that construct a genuine approval request directly.

    Either way, I would avoid a stringly additional property for this one. The distinction is load-bearing for UI, persistence, replay, and policy consumers, so it deserves a first-class typed surface.

    The naming tests I would pin are:

    1. direct approval-required tool defaults to ToolDeclared / IsCollateralRequest == false;
    2. peer wrapped only because another tool in the batch required approval becomes BatchCollateral / true;
    3. serialized and rehydrated content preserves the value;
    4. non-FICC producers get the genuine/default behavior unless they explicitly mark the request as collateral.
  11. javiercn commented on Jun 10, 2026

    @javiercn
    MemberAuthor

    Thanks @jozkee. Agreed that IsInvokerRequested pulls FICC vocabulary into Abstractions. The property should describe the request, not who created it.

    Here are some options

    Name Reads as
    RequiresExplicitApproval if (req.RequiresExplicitApproval) Prompt(); else AutoApprove();
    RequiresUserApproval if (req.RequiresUserApproval) ...
    RequiresConfirmation if (req.RequiresConfirmation) ...
    RequiresReview if (req.RequiresReview) ...

    My pick is RequiresConfirmation

    1. Simplest single word. No jargon, no new vocabulary; any developer reads it correctly the first time.
    2. Doesn't assume who decides. Confirmation can come from a user prompt, a policy engine, a CI gate, or an agent acting for someone. RequiresUserApproval only fits the first.
    3. Avoids RequiresApproval on ToolApprovalRequestContent, which reads as a contradiction.
    4. Reads naturally for UI prompts, policy gates, and telemetry tagging.
    5. Safe default. Direct producers get the correct value (true) without writing anything; FICC is the only piece of code that sets false.
  12. westey-m commented on Jun 10, 2026

    @westey-m
    Contributor

    RequiresConfirmation seems reasonable.

    I think it's important to consider if this property can/should be more general purpose. E.g. if someone has a stateless stack, but wants to add a chat client decorator that uses heuristics to auto approve some functions, that decorator could flip this property on additional approval requests to essentially pre-approve them. If all end up with RequiresConfirmation=false, reinvocation can happen immediately, but if any still have RequiresConfirmation=true, they would all need to be returned to the caller.

    I think IsCollateralRequest has a slightly more specific meaning and while it could still be used to also mark pre-approved approval requests in this way, I think RequiresConfirmation will be easier to grasp for more folks.

    Aside: heuristics like these would more likely be based on parameter values, rather than function names, since if a function never requires approval, the developer can usually just avoid marking it as requiring approval. But heuristics are useful, where approval may be based on, for example, the value of a parameter exceeding a certain value.

  13. javiercn commented on Jun 10, 2026

    @javiercn
    MemberAuthor

    RequiresConfirmation seems reasonable.

    I think it's important to consider if this property can/should be more general purpose. E.g. if someone has a stateless stack, but wants to add a chat client decorator that uses heuristics to auto approve some functions, that decorator could flip this property on additional approval requests to essentially pre-approve them. If all end up with RequiresConfirmation=false, reinvocation can happen immediately, but if any still have RequiresConfirmation=true, they would all need to be returned to the caller.

    I think IsCollateralRequest has a slightly more specific meaning and while it could still be used to also mark pre-approved approval requests in this way, I think RequiresConfirmation will be easier to grasp for more folks.

    Aside: heuristics like these would more likely be based on parameter values, rather than function names, since if a function never requires approval, the developer can usually just avoid marking it as requiring approval. But heuristics are useful, where approval may be based on, for example, the value of a parameter exceeding a certain value.

    I would think that by the time this property flows to the consumers, the turn has effectively ended and the mechanism to "auto approve" is to programmatically create the approval response and trigger the new turn.

    One additional suggestion in terms of naming, could be RequiresInteraction. I think IsCollateralRequest is somewhat obscure and I really don't like it. (It's one of the first things copilot suggested for naming). It is hard to explain to people compared to RequiresConfirmation or RequiresInteraction.

    I lean towards RequireConfirmation (and I've updated the companion PR to reflect it) but we can also consider RequiresInteraction or InteractionRequired. None of them I like more but are also options.

  14. rpelevin commented on Jun 10, 2026

    @rpelevin

    RequiresConfirmation seems workable to me if the semantics stay explicit.

    I would read it as: this approval request still needs an external decision before the next invocation. So false should mean "no external confirmation remains outstanding," not "this action needed no authority record."

    The case I would avoid is letting RequiresConfirmation = false become an unrecorded authority grant. If a decorator or policy engine uses heuristics to resolve an approval request automatically, I would still want that resolution to be represented somewhere as a real decision/resolution: source, reason or policy version, decided_at, and the exact tool/args request it resolved.

    Then consumers can distinguish:

    1. no confirmation needed because this request was collateral/batch-coherence only;
    2. no confirmation needed because policy already resolved it;
    3. confirmation still needed from the caller/user/system.

    Tests I would pin:

    1. a direct approval-required tool defaults to RequiresConfirmation = true;
    2. a collateral request that exists only to preserve batch shape can be false;
    3. a heuristic or policy pre-resolution can set false only with a recorded resolution tied to the same request;
    4. changing args after that automatic resolution requires re-evaluation, not reuse;
    5. serialization/roundtrip preserves the value and any resolution/provenance fields;
    6. if any request in a batch remains true, the batch returns for confirmation; if all are false, reinvocation is allowed only under the recorded resolutions.

    So I would be comfortable with RequiresConfirmation / RequiresInteraction as the public-facing name. The main contract I would preserve is the authority distinction: false means no external confirmation remains outstanding; it should not erase why that request no longer needs confirmation.

  15. jozkee commented on Jun 10, 2026

    @jozkee
    Member

    +1 to RequiresConfirmation.

  16. westey-m commented on Jun 10, 2026

    @westey-m
    Contributor

    The case I would avoid is letting RequiresConfirmation = false become an unrecorded authority grant. If a decorator or policy engine uses heuristics to resolve an approval request automatically, I would still want that resolution to be represented somewhere as a real decision/resolution: source, reason or policy version, decided_at, and the exact tool/args request it resolved.

    Resolution is captured on approval responses (see ToolApprovalResponseContent.Reason), not on approval requests. RequiresConfirmation=false should simply be considered as an indication that the caller doesn't need to present this to a user for confirmation. The RequiresConfirmation naming is clearly broad enough to encompass many reasons for this. If we want it to only mean "tool calls that don't require approval because they are are collateral from FICC", then RequiresConfirmation is the wrong name. However, I think that broad is better in this case and therefore RequiresConfirmation is appropriate.

  17. rpelevin commented on Jun 10, 2026

    @rpelevin

    That split works for me.

    If ToolApprovalResponseContent is the durable resolution surface, then I would keep RequiresConfirmation narrowly as "does the caller have to stop and ask before continuing?" rather than "was authority ever needed?"

    The cases I would distinguish are:

    • collateral or batch-coherence request: no confirmation is needed because this item was never the authority-bearing request;
    • policy or heuristic pre-resolution: no caller interaction is needed because a resolver already produced the corresponding approval response for this exact request;
    • unresolved request: confirmation is still required.

    So I agree broad RequiresConfirmation is the better name. The invariant I would keep is that false suppresses caller interaction; it should not become the only evidence that an approval-required action was resolved.

    The test boundary I would pin:

    1. collateral request can carry RequiresConfirmation = false;
    2. policy-resolved request can carry RequiresConfirmation = false only when the matching response/reason exists for the same request;
    3. reinvocation proceeds only when every request either needs no confirmation by construction or has a matching approval response;
    4. changed tool name/args after a policy-created response requires a new resolution;
    5. serialized history preserves enough request flag plus response reason to explain why no prompt was shown.
  18. locked and limited conversation to collaborators on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ai

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions