[bot] OpenAI ResponseStream `text` method bypasses instrumentation
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- ruby
調査の方向性
lib/braintrust/contrib/openai/instrumentation/responses.rb:118-183 から始めます。ここでは現在、ResponseStream が各 each をラップしています。lib/braintrust/contrib/openai/instrumentation/chat.rb:140-225 の対応するテキスト処理と比較してください。lib/braintrust/contrib/openai/patcher.rb:113-119 を確認してパッチ対象のクラスを特定し、その後、text を介して ResponseStream を消費すると、each を使用した場合でも二重に tracing されずに tracing が生成されることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
The OpenAI ResponseStream instrumentation only wraps the each method, but the upstream OpenAI::Helpers::Streaming::ResponseStream class also exposes a text convenience method that bypasses each and returns text deltas directly. Users who consume the Responses API stream via stream.text.each { |t| ... } get zero tracing.
This is inconsistent within the same SDK: the Chat Completions integration wraps both each and text on ChatCompletionStream, but the Responses integration only wraps each on ResponseStream.
What is missing
ResponseStream#text is not wrapped. The upstream SDK's text method returns a fused chain yielding ResponseTextDeltaEvent content that reads from the underlying HTTP stream directly, bypassing the prepended each method on the ResponseStream object.
How the Chat integration handles this (for reference)
The Chat integration wraps both methods on ChatCompletionStream at lib/braintrust/contrib/openai/instrumentation/chat.rb:152-169:
module ChatCompletionStream
module InstanceMethods
def each(&block) # line 152 — wrapped ✓
...
end
def text # line 159 — wrapped ✓
...
Enumerator.new do |y|
trace_consumption(ctx) do
original_enum.each { |t| y << t }
end
end
end
end
end
The same pattern should be applied to ResponseStream. The ctx[:consumed] guard already prevents double-tracing when both text and each are wrapped on the same object.
Upstream ResponseStream methods
The upstream class (OpenAI::Helpers::Streaming::ResponseStream) exposes:
each— wrapped ✓text— NOT wrapped ✗ — bypasseseach, reads from internal stream directlyuntil_done— covered (callseachinternally)get_final_response— covered (consumes stream viaeach)get_output_text— covered (delegates toget_final_response)
Only text needs a wrapper because it is the only consumption method that bypasses each.
Braintrust docs status
not_found — Braintrust docs do not mention text as a stream consumption method or differentiate between stream consumption patterns.
Upstream sources
- OpenAI Ruby SDK
ResponseStream: https://github.com/openai/openai-ruby/blob/main/lib/openai/helpers/streaming/response_stream.rb — definestext,until_done,get_final_response,get_output_text - OpenAI Ruby SDK
ChatCompletionStream: https://github.com/openai/openai-ruby/blob/main/lib/openai/helpers/streaming/chat_completion_stream.rb — definestext(already wrapped by this SDK)
Local repo files inspected
lib/braintrust/contrib/openai/instrumentation/responses.rb:118-183—ResponseStreammodule only wrapseach(line 128)lib/braintrust/contrib/openai/instrumentation/chat.rb:140-225—ChatCompletionStreammodule wraps botheach(line 152) andtext(line 159)lib/braintrust/contrib/openai/patcher.rb:113-119—ResponsesPatcher.patch_response_streampatchesResponseStreamclass
- 主要言語
- Ruby
- スター
- 9
- フォーク
- 11
- 平均マージ
- 3日 43分
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
braintrustdata/braintrust-sdk-ruby のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
braintrustdata/braintrust-sdk-ruby#143 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
braintrustdata/braintrust-sdk-ruby#137 ·
メンテナーはふだん 1 日以内に返信
-
ruby
難易度 3/5 半日 初心者へのやさしさ 62/100
braintrustdata/braintrust-sdk-ruby#229 ·
メンテナーはふだん 1 日以内に返信
-
ruby
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
braintrustdata/braintrust-sdk-ruby#228 ·
メンテナーはふだん 1 日以内に返信
-
ruby
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
braintrustdata/braintrust-sdk-ruby#227 ·
メンテナーはふだん 1 日以内に返信
braintrustdata/braintrust-sdk-ruby の issue をすべて見る
似ている issue
-
Unconfirmed users who reset their password are stuck on sign in with no way to send confirmationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
L: github:actions L: javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dependabot/dependabot-core#16615 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
hitobito/hitobito_pfadi_de#164 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 7 日以内に返信