Skip to content

fix(streaming): handle dupe-index delta entries - #3204

Closed
hrolfurinn wants to merge 1 commit into
openai:mainfrom
hrolfurinn:fix/accumulate-delta-duplicate-index
Closed

hrolfurinn wants to merge 1 commit into
openai:mainfrom
hrolfurinn:fix/accumulate-delta-duplicate-index

Conversation

@hrolfurinn

@hrolfurinn hrolfurinn commented May 7, 2026

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Handles case where multiple tool call entries in a single streaming delta share the same index. That dupe index shape is permissible according to the spec. Previously could result in initial tool call arg chunk being dropped, e.g. intended arguments { "city": "Reykjavik"} become truncated city": "Reykjavik" } . Bug was observed against vLLM with spec. decoding enabled.

Route the first delta through the index-merge path. Duplicate-index entries now merge instead of becoming separate list elements. The early-return branches (key not in acc, acc_value is None) copied the delta list as-is, skipping the merge. Same fix in _assistants.py. _completions.py now seeds initial snapshots through accumulate_delta.

Additional context & links

Fixes #3201

@hrolfurinn
hrolfurinn requested a review from a team as a code owner May 7, 2026 01:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57597c785c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openai/lib/streaming/_deltas.py
@marcuswood-oai

Copy link
Copy Markdown
Contributor

Thanks for taking the time to work on this! We’ve merged the fix for duplicate-index tool-call deltas in #3425, so I’m closing this as a duplicate. We appreciate the contribution.

@hrolfurinn

Copy link
Copy Markdown
Author

@marcuswood-oai Glad to see a fix is in. Would have appreciated you landing it via this PR.

Regardless, glad it's closed. My inbox has been crowded by AI PR dupes referencing this fix for the past four months. And also with comments on Chris' original Issue he posted when we found the bug.

I can't imagine what your inbox must look like.

Happy someone's tying up all the loose ends.

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.

Streaming tool_call deltas with duplicate indexes in first chunk are accumulated incorrectly

2 participants