Repository navigation
fix(core): keep parallel streamed tool calls apart in Azure and Copilot adapters - #652
Merged
JackChen-me merged 2 commits intoNov 4, 2026
Conversation
…ot adapters Both stream handlers keyed their tool-call buffers by `toolCallDelta.index`. Servers that omit `index` (Gemini-style OpenAI endpoints) made every call share one `undefined` buffer, so parallel calls collapsed into one with merged, invalid arguments. Move the slot selection added to the OpenAI adapter in open-multi-agent#642 into a shared helper in openai-common.ts and use it in the OpenAI, Azure and Copilot adapters. Behavior is unchanged when `index` is present.
JackChen-me
approved these changes
Nov 4, 2026
JackChen-me
left a comment
Member
There was a problem hiding this comment.
LGTM — the shared slot resolver is a line-for-line extraction of the #642 OpenAI logic, Azure and Copilot now handle unindexed parallel tool calls, and existing OpenAI tests still cover the refactor. CI is green. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AzureOpenAIAdapter.stream()andCopilotAdapter.stream()now keep parallel streamed tool calls apart when the server omitsindex. The slot selection that #642 added toOpenAIAdaptermoves into a shared helper,createToolCallSlotResolverinopenai-common.ts, and all three adapters use it. When the server sendsindex, behavior is unchanged.Motivation
Both handlers did
const idx = toolCallDelta.indexand used it as the key oftoolCallBuffers. A server that omitsindex(Gemini's OpenAI-compatible endpoint, the case in #642) makes every call share theundefinedkey, so parallel calls collapse into one buffer. #642 fixed onlyopenai.ts.Repro through each adapter's
stream()with a mocked client: two whole tool calls in separate chunks, idscall_1/call_2, arguments{"city":"Paris"}/{"city":"Tokyo"}, noindex.tool_use, idcall_2,input: {}tool_useblocks with their own ids and inputstool_use, idcall_2,input: {}tool_useblocks with their own ids and inputsThe input is
{}before because the two argument strings are concatenated into invalid JSON, which these handlers surface as an empty object.Scope and impact
llm/azure-openai.ts,llm/copilot.ts,llm/openai-common.ts,llm/openai.ts, plus tests.openai.tschanges only to call the shared helper in place of its inline copy of the same logic; the existing OpenAI tests, including the ones from fix(openai): keep parallel streamed tool calls apart when the server omits index #642, still pass.deepseek.tsextendsOpenAIAdapterand inherits its stream handler, andai-sdk.tsdelegates to the SDK bridge instead of reading raw deltas. Azure, Copilot and OpenAI are the only places that readtoolCallDelta.index.openai-common.tslike the other shared helpers there; it is not part of the package entry point.Validation
Node 24, from
packages/coreon Windows:npx vitest run azure-openai-adapter copilot-adapter openai-adapter openai-fallback openai-common openai-sdk-boundary --maxWorkers=2 --minWorkers=1: 122 passed.azure-openai.tsandcopilot.tschanges reverted (helper andopenai.tskept): the two new "keeps parallel tool calls apart when the server omits index" tests fail (received onetool_usewithinput: {}, expected two), 63 other tests in those two files pass. The "fragments that have neither index nor id" tests pass with and without the change; they pin the continuation behavior.npm run lint(tsc --noEmit -p tsconfig.lint.json): clean.git diff --check: clean.npx vitest run --maxWorkers=2 --minWorkers=1(all of core): 2329 passed, 27 skipped, 31 failed. All 31 failures are incli.test.ts(dashboard file export),eval-file-store.test.tsandfile-trace-store.test.ts, and the ones I inspected reportSYNC_FAILED ... causeCode: 'EPERM'from the Windows filesystem. None touch the LLM adapters; I did not investigate them further.Not run:
npm run build,npm run test:zod3,npm run test:scaffold, other workspaces, or any request to a live Azure or Copilot endpoint.Checklist