Skip to content

fix: merge streaming tool deltas by logical index#3329

Open
FU-max-boop wants to merge 1 commit into
openai:mainfrom
FU-max-boop:fix/merge-duplicate-tool-call-deltas
Open

fix: merge streaming tool deltas by logical index#3329
FU-max-boop wants to merge 1 commit into
openai:mainfrom
FU-max-boop:fix/merge-duplicate-tool-call-deltas

Conversation

@FU-max-boop
Copy link
Copy Markdown

Summary

  • collapse duplicate indexed list deltas in the initial streaming chunk before storing them in the accumulator
  • merge later indexed entries by their logical index field instead of by physical list position
  • reuse the chat streaming delta accumulator from Assistants streaming so both paths share the fix

Fixes #3201.

Testing

  • uv run python -m pytest tests/lib/test_streaming_deltas.py tests/lib/chat/test_completions_streaming.py -q -o addopts=""
  • uv run ruff check src/openai/lib/streaming/_deltas.py src/openai/lib/streaming/_assistants.py tests/lib/test_streaming_deltas.py
  • uv run ruff format --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

@FU-max-boop FU-max-boop requested a review from a team as a code owner May 28, 2026 18:48
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