You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Go SDK OpenAI streaming drops gen_ai.response.finish_reasons #1983
gen_ai.response.finish_reasons is never set on OpenAI streaming spans.
The streaming client forces stream_options.include_usage = true (streaming.go, createChatCompletionStream). With that option OpenAI sends a final chunk that carries usage and an empty choices array. readStream keeps only lastChunk = &chunk and reads the finish reasons from lastChunk.Choices at the end, so it reads them from the usage chunk, which has none.
Python keeps the finish reason across chunks and reads usage separately (sdk/python/src/openlit/instrumentation/openai/utils.py, where a comment notes the usage chunk has an empty choices list).
The existing TestChatCompletion_Streaming fixture puts finish_reason and usage in the same chunk, which the real API does not do, so it does not catch this.
Steps to reproduce
Serve three SSE chunks from an httptest server: a content delta, a chunk with finish_reason: "stop", and a final chunk with choices: [] and usage. Read the stream to the end and inspect the span.
Expected
gen_ai.response.finish_reasons = ["stop"], together with the usage attributes.
Actual
Usage is recorded, gen_ai.response.finish_reasons is missing.
Activity