Repository navigation
Description
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:
HandleUserInputResponseAsyncmarks the request handled and immediately runsProcessTurnMessagesAsync→ContinueTurnAsync, which invokes the agent with only that oneToolApprovalResponseContent.- With only
c1answered, the agent runsc1, calls the model and finishes the turn. - When
c2's answer arrives, the agent runs again, but its output has noFunctionCallContent/FunctionResultContentforc2.CreateCompletedApprovalResponsethen throws. HasOutstandingRequestsis only checked after the agent has run, to decide whether to emit aTurnToken.
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
github-actions commentedon Nov 10, 2026
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,HandleUserInputResponseAsynccallsContinueTurnAsynconce per approval answer.CreateCompletedApprovalResponsethen throws the reportedInvalidOperationExceptionif 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
MoustAhmed commentedon Nov 14, 2026
Hi Vincent Biret (@baywet), I found an existing precedent for the batching approach proposed above. The harness’s
ToolApprovalAgentaccepts decisions one at a time and passes them to the inner agent together once the batch is resolved. [This xUnit test](agent-framework/dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/ToolApproval/ToolApprovalAgentTests.cs
Line 2274 in 92838b6
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.
baywet commentedon Nov 16, 2026
I've opened #10393 to fix this.