Skip to content

fix(azure-openai): keep parallel streamed tool calls apart - #1522

Open
pcbeingused33 wants to merge 2 commits into
SciSharp:masterfrom
pcbeingused33:fix/azure-openai-parallel-tool-calls
Open

pcbeingused33 wants to merge 2 commits into
SciSharp:masterfrom
pcbeingused33:fix/azure-openai-parallel-tool-calls

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Azure OpenAI streaming now returns all requested tool calls with their individual arguments. The previous reconstruction treated each fragment without an ID as part of the most recently opened call. When the service interleaved fragments, it attached arguments to the wrong call. The OpenAI chat provider used the same reconstruction.

Both providers now group updates by the SDK's tool call index and append arguments in arrival order within each call. They preserve the first nonempty ID and function name for each index and emit calls in index order. The first call still supplies the response's single-call fields.

The provider reconstruction tests cover the index sequence 0, 1, 0, 1 with IDs only on the opening fragments, plus an Azure stream where the ID and name arrive after some arguments. These cases produced three failures against the previous PR head. All 12 reconstruction tests pass with the fix. A local SSE simulation also exercised Azure's public streaming method and verified both tool calls and the first call's single-call fields.

dotnet test tests/BotSharp.Core.UnitTests/BotSharp.Core.UnitTests.csproj --filter FullyQualifiedName~StreamingToolCallReconstructionTests

This change was prepared with assistance from an AI coding tool.

The streaming path joined the argument fragments of every tool call into one string and reported only the first name and id, so a reply asking for two tools produced malformed arguments. Rebuild the calls per tool call id, as the OpenAI plugin does, and report them all in ToolCalls.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@pcbeingused33

Copy link
Copy Markdown
Contributor Author

The follow-up fixes interleaved tool-call fragments by using the SDK's index in both Azure OpenAI and OpenAI chat streaming. Regression coverage includes interleaving and an ID that arrives after part of the arguments.

This comment was drafted with Claude Code.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant