Repository navigation
fix(ai): keep streamed OpenAI tool calls that have no index - #1091
Merged
marandaneto merged 4 commits intoOct 23, 2026
Merged
marandaneto merged 4 commits into
marandaneto merged 4 commits into
Conversation
marandaneto
reviewed
Oct 21, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
Automated advisory code review.
Contributor
Author
|
Thanks, good catch. Fixed in 8fed35a: calls without an index now get keys of their own ( |
marandaneto
reviewed
Oct 22, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
Automated advisory code review.
accumulate_openai_tool_calls skipped every delta without an index, so tool calls from OpenAI-compatible providers that omit it never reached $ai_output. A delta with a new id now opens a call, and one without an id continues the latest call. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A call without an index took key max + 1, which a later call with that real index overwrote, merging two calls and dropping one. Index-less calls now get string keys of their own. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
marandaneto
force-pushed
the
fix/openai-stream-tool-calls-without-index
branch
from
October 23, 2026 09:01
a0f8122 to
3a9320f
Compare
marandaneto
approved these changes
Oct 23, 2026
Member
|
thanks @pcbeingused333 |
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.
💡 Motivation and Context
accumulate_openai_tool_callsskipped every tool call delta whoseindexisNone. Some OpenAI-compatible providers send streamed tool calls without anindex, so those calls never reached$ai_outputfor the Chat Completions streaming wrappers (sync and async share this function).A delta without an index is now matched by its
idwhen one is present and already known. Otherwise a delta with a newidor a function name opens a new call, and a delta with neitheridnor function name appends its arguments to the latest call. Deltas with an index take the same path as before.💚 How did you test it?
posthog/test/ai/openai/test_openai_converter.py: two index-less calls sent whole through_ChatCompletionsStreamState, argument fragments joined onto the latest call, two whole calls with a name and neitheridnorindexgiving two calls, and a guard that indexed deltas behave as before. All but the guard fail on main (the calls are dropped).posthog/test/ai: 1069 passed, 15 skipped.ruff checkreports the same 54 findings as on main;ruff formatis clean on the changed lines.📝 Checklist
If releasing new changes
sampo addto generate a changeset file (added.sampo/changesets/openai-stream-tool-calls-without-index.mdin the same format)🤖 Agent context
Autonomy: Fully autonomous
idand then by function name is a heuristic for providers that send each call whole; a provider that interleaves several index-less calls with partial arguments and no ids cannot be told apart, and a continuation fragment that repeats the function name would open a new call.🤖 Generated with Claude Code