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
openai 3.23.0 made client.beta.agents.sessions.create(stream=True) return AgentSessionEventStream, which adds with_result_collection() and get_final_result() (and an output_type= kwarg on create).
Our _TracedStream / _AsyncTracedStream wrappers in py/src/braintrust/integrations/openai/tracing.py (returned from AgentSessionWrapper.create / acreate) are NamedWrappers whose __getattr__ forwards unknown attributes to the real stream. So:
stream.get_final_result() runs on the real stream, which iterates itself and calls close(). _AgentSessionTrace.observe() / finish() never run, so the openai.agents.sessions.create span gets no output, metrics or tool spans and is never ended.
stream.with_result_collection() returns the real stream (self), so iterating its return value also skips tracing.
Fix
Implement get_final_result() on the traced wrappers (or a session-specific subclass): drain through the traced generator, then call the wrapped stream's get_final_result(). Optionally log result.output as the span output.
Make with_result_collection() call the wrapped method and return the traced wrapper.
Add a cassette-backed test next to the existing session stream tests in test_openai.py. Gate it on openai >= 3.23.0.
Parent: #858 (found while reviewing the 2026-10-05 weekly dependency update, #849).
Activity
AbhiPrasad commentedon Oct 5, 2026
fix released with https://github.com/braintrustdata/braintrust-sdk-python/releases/tag/py-sdk-v0.44.1
fix(openai): trace agent session result collection (braintrustdata#873)