fix(open-9027): azure openai tracer fix for chunks#597
Merged
gustavocidornelas merged 1 commit intomainfrom Feb 17, 2026
Conversation
viniciusdsmello
approved these changes
Feb 17, 2026
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.
Pull Request
Summary
Fixes tracer crashes when using
trace_openaiwith streaming on Azure OpenAI. Handles (1) stream chunks with emptychoices(e.g. heartbeats) and (2) empty or invalid function-call arguments sojson.loadsno longer raises.Changes
openai_tracer.py,async_openai_tracer.py, andgroq_tracer.py, streaming loops now usegetattr(chunk, "choices", None)and skip chunks with no choices before accessingchunk.choices[0].delta, avoidingIndexError: list index out of range.openai_tracer.py(parse_non_streaming_output_data),async_openai_tracer.py(streamingfinallyblocks), andgroq_tracer.py(streaming + non-streaming), only calljson.loadswhen the arguments string is non-empty and wrap in try/except forJSONDecodeError, avoiding "Expecting value: line 1 column 1 (char 0)" on empty/invalid JSON.Context
Azure OpenAI can send stream chunks with empty
choices(e.g. heartbeat chunks) and function-call arguments can be empty or incomplete. The tracer was assuming every chunk hadchoices[0]and that arguments were valid JSON, which caused "Failed yield chunk. list index out of range" and "Failed to trace… Expecting value: line 1 column 1 (char 0)" when implementing the openai-chatbot template with Azure + streaming.Testing