Skip to content

Commit c5bfe58

Browse files
authored
fix(openai): re-export NamedWrapper from braintrust.oai for back-compat (#319)
autoevals imports NamedWrapper from braintrust.oai to detect whether an OpenAI client has already been wrapped by the Braintrust SDK. After the 0.15.0 refactor moved the class to braintrust.integrations.openai.tracing, the import silently fell back to an internal stub, so isinstance checks no longer matched braintrust-wrapped clients. autoevals then re-wrapped with its own non-tracing shim, dropping scorer spans (openai.responses.create and Embedding calls with purpose="scorer") across a number of expect tests. Re-export NamedWrapper from braintrust.oai so autoevals' existing detection path keeps working.
1 parent 8132baa commit c5bfe58

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/src/braintrust/oai.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
from braintrust.integrations.openai import OpenAIIntegration, wrap_openai
22

3+
# NamedWrapper is re-exported here for back-compat. autoevals imports it from
4+
# `braintrust.oai` to detect OpenAI clients that the Braintrust SDK has already
5+
# wrapped (see autoevals/oai.py); if the import fails, autoevals falls back to
6+
# an internal stub and its isinstance check misses real wrapped clients,
7+
# causing scorer LLM calls to be re-wrapped without tracing.
8+
from braintrust.integrations.openai.tracing import NamedWrapper
9+
310

411
def patch_openai() -> bool:
512
"""Patch OpenAI globally for Braintrust tracing."""
613
return OpenAIIntegration.setup()
714

815

916
__all__ = [
17+
"NamedWrapper",
1018
"patch_openai",
1119
"wrap_openai",
1220
]

0 commit comments

Comments
 (0)