Skip to content

OpenAI: responses.stream() helper method not instrumented #170

@braintrust-bot

Description

@braintrust-bot

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

Local files inspected

  • py/src/braintrust/oai.pyResponsesV1Wrapper (line 873) and AsyncResponsesV1Wrapper (line 892) define create() and parse() only; no stream() method
  • py/src/braintrust/wrappers/test_openai.py — no tests for responses.stream()
  • py/src/braintrust/wrappers/openai.py — re-exports from oai.py, no additional stream() handling

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions