Skip to content

Fix parallel tool calls shared index#2

Open
baya wants to merge 4 commits into
nowa:mainfrom
longbridge:fix-parallel-tool-calls-shared-index
Open

Fix parallel tool calls shared index#2
baya wants to merge 4 commits into
nowa:mainfrom
longbridge:fix-parallel-tool-calls-shared-index

Conversation

@baya

@baya baya commented Jul 17, 2026

Copy link
Copy Markdown

No description provided.

蒋桂民 and others added 4 commits July 18, 2026 00:42
…current call

Some OpenAI-compat gateways (observed: an Anthropic-to-OpenAI translation
gateway) emit argument-continuation chunks carrying no index, no id, and
no function.name. The accumulator's lookup missed on both maps and
created a phantom ToolCall block, so the argument deltas landed on the
phantom while the real call finalized with empty arguments {} and failed
tool schema validation downstream.

Track the last-touched tool-call block on the stream processor and fall
back to it when a delta identifies itself in no other way; creating a
new block remains the final fallback for a genuinely new call.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
std::env::temp_dir() returns a /var/... path that is a symlink to
/private/var/..., while the shell reports the resolved path in $PWD.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…l-call-deltas

fix(openai-completions): route bare tool-call argument deltas to the current call
…index 0

Live capture from an Anthropic-to-OpenAI translation gateway shows
parallel tool calls are not renumbered: every call arrives with index 0,
distinguished only by its fresh id+name header chunk. Keying the
accumulator by index alone concatenated call B's arguments onto call A
('{...}{...}'), the JSON parse failed, and BOTH calls finalized with
empty arguments {} — downstream tool validation then rejected them
(read_file/run_shell with missing required fields).

Treat a header chunk (non-empty id AND name) whose id conflicts with the
block mapped at that index as a new tool call and remap the index to it.
The name requirement keeps streams whose continuation chunks carry
rotating junk ids but never a name (e.g. kimi) coalescing by stable
index exactly as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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