Skip to content

.NET: [Bug]: Workflow agent host fails when one response contains two approval-required tool calls #10256

Description

@ikebig2

Description

When an agent hosted in a workflow returns two approval-required tool calls in one model response, answering both approval requests fails the run. Only the first tool executes. The second answer ends with:

System.InvalidOperationException: The agent did not return a function call and result for approval request 'ficc_c2' with call id 'c2'.

It fails the same way whether both approvals are answered together (two SendResponseAsync calls before watching the stream again) or one at a time.

Versions

  • Microsoft.Agents.AI.Workflows 1.28.0 / Microsoft.Agents.AI 1.28.0
  • Microsoft.Extensions.AI 10.11.0
  • .NET 10

Repro (framework only)

A scripted IChatClient returns two FunctionCallContents for an ApprovalRequiredAIFunction on its first call, then a text reply once it sees tool results.

var toolRuns = 0;
var echo = new ApprovalRequiredAIFunction(AIFunctionFactory.Create((string text) => { Interlocked.Increment(ref toolRuns); return text; }, "echo"));
var client = new TwoCallsClient(); // 1st call: [FunctionCallContent("c1","echo",{text:"a"}), FunctionCallContent("c2","echo",{text:"b"})]; afterwards: text
var agent = new ChatClientAgent(client, new ChatClientAgentOptions { Name = "clerk", ChatOptions = new ChatOptions { Tools = [echo] } });
var workflow = AgentWorkflowBuilder.BuildSequential([agent]);

await using var run = await InProcessExecution.RunStreamingAsync(workflow, new List<ChatMessage> { new(ChatRole.User, "echo a and b") });
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));

var requests = new List<(ExternalRequest Request, ToolApprovalRequestContent Content)>();
await foreach (var evt in run.WatchStreamAsync(false))
    if (evt is RequestInfoEvent r && r.Request.TryGetDataAs(out ToolApprovalRequestContent? c)) requests.Add((r.Request, c!));
// requests.Count == 2

foreach (var (request, content) in requests)
    await run.SendResponseAsync(request.CreateResponse(content.CreateResponse(true)));
await foreach (var evt in run.WatchStreamAsync(false)) { /* collect ExecutorFailedEvent */ }

Observed: toolRuns == 1, the model is called 3 times, and an ExecutorFailedEvent is raised with the exception above.

Expected: both tools run once (toolRuns == 2), and the agent continues with both results in one turn, the same as FunctionInvokingChatClient does when it receives both approval responses together.

Analysis

Reading Specialized/AIAgentHostExecutor.cs (main), each approval answer seems to be processed on its own:

  • HandleUserInputResponseAsync marks the request handled and immediately runs ProcessTurnMessagesAsync → ContinueTurnAsync, which invokes the agent with only that one ToolApprovalResponseContent.
  • With only c1 answered, the agent runs c1, calls the model and finishes the turn.
  • When c2's answer arrives, the agent runs again, but its output has no FunctionCallContent/FunctionResultContent for c2. CreateCompletedApprovalResponse then throws.
  • HasOutstandingRequests is only checked after the agent has run, to decide whether to emit a TurnToken.

A possible fix: buffer approval answers until every outstanding approval request of the same agent turn is answered, then continue the turn once with all of them.

Workaround

We currently keep agents that have approval-required tools at one tool call per model response (ChatOptions.AllowMultipleToolCalls = false, enforced in a chat-client middleware). That avoids the failure, but every tool call costs an extra model round-trip.

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 10, 2026
  2. added
    needs-maintainer-triageUsage: [Issues], Target: all issues that the automated triage flow failed to process
    on Nov 10, 2026
  3. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Thanks for the detailed report. Routed to the Workflows owner. Result: inconclusive, not reproduced. I did not run a test in this pass, so this is source-only evidence.

    In Specialized/AIAgentHostExecutor.cs, HandleUserInputResponseAsync calls ContinueTurnAsync once per approval answer. CreateCompletedApprovalResponse then throws the reported InvalidOperationException if that agent output has no call and result for that call id. That is consistent with your analysis, though it is not confirmed by a run.

    Support boundary: unclear. I found no maintained spec or ADR saying whether multiple approval requests in one agent turn are directly supported, so a maintainer needs to decide that.

    Run: https://github.com/microsoft/agent-framework/actions/runs/42923651833

    Generated by Issue Routing for #10256 · copilot · auto · ~21 AIC · ⌖ ~1 AIC · ⊞ 5.2K · ◷

  4. MoustAhmed commented on Nov 14, 2026

    @MoustAhmed
    Contributor

    Hi Vincent Biret (@baywet), I found an existing precedent for the batching approach proposed above. The harness’s ToolApprovalAgent accepts decisions one at a time and passes them to the inner agent together once the batch is resolved. [This xUnit test](

    public async Task RunAsync_AllQueuedResolved_CallsInnerAgentWithCollectedResponsesAsync()
    ) covers that behavior.

    Should the workflow host follow the same pattern for approval requests from a single turn? If you’re open to an external PR, I’d be happy to adapt it and add a Workflows regression test that submits the two approvals separately, checks that neither tool runs after the first answer, and verifies that both run exactly once after the second.

  5. baywet commented on Nov 16, 2026

    @baywet
    Member

    I've opened #10393 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .Netneeds-maintainer-triageUsage: [Issues], Target: all issues that the automated triage flow failed to processtriageUsage: [Issues], Target: All issues that still need to be triaged

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions