-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
The OpenAI Python SDK's client.responses.stream() dedicated streaming helper is not instrumented by wrap_openai(). Calls to it fall through via NamedWrapper.__getattr__ to the unwrapped SDK, producing zero Braintrust tracing — no spans, no token metrics, no timing.
Only responses.create(stream=True) and responses.parse() are wrapped today.
What's missing
responses.stream() returns a high-level ResponseStream / AsyncResponseStream context manager that provides:
- Event-driven iteration with typed events and
.on("event_type", handler)callbacks - Built-in accumulation via
.get_final_response()after stream completion - Convenience helpers like
.text_stream(yields only text deltas) and.until_done() - Context manager resource cleanup (
with client.responses.stream(...) as stream:)
This is the recommended streaming pattern in the OpenAI SDK docs and is distinct from the raw create(stream=True) iterator path that is already instrumented.
A parallel gap exists for chat.completions.stream() (tracked in #114). This issue covers the Responses API equivalent.
Braintrust docs status
The OpenAI integration page does not mention responses.stream(). Status: not_found.
Upstream sources
- OpenAI Python SDK — Streaming Responses documents
client.responses.stream()as a first-class helper - OpenAI API Reference — Streaming
Local files inspected
py/src/braintrust/oai.py—ResponsesV1Wrapper(line 873) andAsyncResponsesV1Wrapper(line 892) definecreate()andparse()only; nostream()methodpy/src/braintrust/wrappers/test_openai.py— no tests forresponses.stream()py/src/braintrust/wrappers/openai.py— re-exports fromoai.py, no additionalstream()handling