Skip to content

fix: merge streaming deltas by logical index#3382

Open
Zhang-986 wants to merge 1 commit into
openai:mainfrom
Zhang-986:codex/merge-duplicate-tool-call-indexes
Open

fix: merge streaming deltas by logical index#3382
Zhang-986 wants to merge 1 commit into
openai:mainfrom
Zhang-986:codex/merge-duplicate-tool-call-indexes

Conversation

@Zhang-986

Copy link
Copy Markdown

Summary

  • merge indexed streaming list deltas by the entry's logical index field instead of the entry's physical list position
  • normalize indexed lists when they first appear so duplicate-index tool call fragments in the first chunk are folded together
  • apply the same fix to the shared chat accumulator and the assistants accumulator

Fixes #3201.

Tests

  • uv run pytest tests/lib/test_streaming_deltas.py (fails before the fix, passes after)
  • uv run pytest tests/lib/test_streaming_deltas.py tests/lib/chat/test_completions_streaming.py tests/lib/test_assistants.py
  • uv run ruff check src/openai/lib/streaming/_deltas.py src/openai/lib/streaming/_assistants.py tests/lib/test_streaming_deltas.py
  • uv run pyright src/openai/lib/streaming/_deltas.py src/openai/lib/streaming/_assistants.py tests/lib/test_streaming_deltas.py
  • git diff --check

@Zhang-986 Zhang-986 requested a review from a team as a code owner June 8, 2026 08:35

@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: c723b6e101

ℹ️ 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
@Zhang-986

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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".

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

1 participant