Skip to content

.NET: [Bug]: AsAIAgent serializes parallel tool calls returned in one Responses result #7640

Description

Description

What happened?

A controlled test with three independent AIFunctions localized tool-call serialization to the Agent Framework AsAIAgent() execution layer.

The raw first Responses API result contained all three function calls in one response: ToolA, ToolB, and ToolC. The request also contained parallel_tool_calls=True. However, when the same tools were executed through AsAIAgent(), each tool started only after the previous tool completed.

Steps to reproduce

  1. Create three independent AIFunctions. Each function delays for 5 seconds and returns its name.
  2. Create the Responses-backed chat client with AIProjectClient.ProjectOpenAIClient.GetProjectResponsesClientForModel(...).AsIChatClient(...).
  3. Set AllowMultipleToolCalls = true and use a CreateResponseOptions with ParallelToolCallsEnabled = true.
  4. Send a prompt that requires all three independent tools in one turn.
  5. Inspect the first raw OpenAI.Responses.ResponseResult; it contains all three function calls.
  6. Execute the same setup through AsAIAgent() and record each function's start and completion time.

Expected behavior

When a model response contains multiple independent function calls and parallel tool calls are enabled, AsAIAgent() should invoke those calls concurrently. The three 5-second functions should take approximately 5 seconds of tool execution time.

Actual behavior

AsAIAgent() invokes the calls sequentially. The three functions take approximately 15 seconds of tool execution time, and total agent wall time was 29,476 ms.

Code Sample

IChatClient chatClient = projectClient.ProjectOpenAIClient
    .GetProjectResponsesClientForModel("gpt-5-mini")
    .AsIChatClient("gpt-5-mini");

var options = new ChatOptions
{
    Tools = [toolA, toolB, toolC],
    AllowMultipleToolCalls = true,
    RawRepresentationFactory = _ => new CreateResponseOptions
    {
        ParallelToolCallsEnabled = true
    }
};

// Each tool independently awaits Task.Delay(TimeSpan.FromSeconds(5))
// and returns its own name.
var response = await chatClient.AsAIAgent().RunAsync(
    "In one turn, call ToolA, ToolB, and ToolC independently.",
    options);


The decisive comparison also inspected the first raw Responses result before `AsAIAgent()` execution and found three function calls: `ToolA`, `ToolB`, and `ToolC`.

Error Messages / Stack Traces

parallel_tool_calls=True
raw_response_type=OpenAI.Responses.ResponseResult
first_response_function_calls=3
first_response_tools=ToolA,ToolB,ToolC

ToolA started=07:48:33.736 completed=07:48:38.741
ToolB started=07:48:38.748 completed=07:48:43.758
ToolC started=07:48:43.760 completed=07:48:48.767
as_ai_agent_wall_ms=29476

Package Versions

Microsoft.Agents.AI (AsAIAgent; exact package version not captured in TestTRS report)

.NET Version

.NET runtime version not captured in TestTRS report

Additional Context

  • Model: gpt-5-mini
  • API path: Foundry project Responses client via GetProjectResponsesClientForModel(...).AsIChatClient(...)
  • ResponseFormat was not set.
  • AllowMultipleToolCalls = true.
  • CreateResponseOptions.ParallelToolCallsEnabled = true.
  • Exact Agent Framework package version from the TestTRS run was not captured in the report.

This separates call generation from execution: the model and Responses API generated the parallelizable response correctly, while serialization occurred afterward in the Agent Framework tool-invocation loop used by AsAIAgent().

This also affects Hosted MCP scenarios, where independent tool calls are observed to execute serially and client-side concurrent MCP invocation is not an acceptable substitute.

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agentreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions