Skip to content

feat(openai): migrate openai wrapper and add claude agent sdk integration#206

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
abhi-refactor-migrate-openai-wrapper-to-integrations
Open

feat(openai): migrate openai wrapper and add claude agent sdk integration#206
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
abhi-refactor-migrate-openai-wrapper-to-integrations

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

Move OpenAI wrapper tests, cassettes, and tracing code from wrappers/ into integrations/openai/. Split OpenAI Agents SDK tracing processor into its own integrations/openai_agents/ package with a dedicated test_openai_agents nox session.

Add new Claude Agent SDK integration under integrations/ with subprocess transport-level cassette support.

The old wrappers/openai.py now re-exports BraintrustTracingProcessor from the new location for backward compatibility. Test paths in noxfile.py are updated to point at the new integration directories.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the abhi-refactor-migrate-openai-wrapper-to-integrations branch from a12f43b to 50dae47 Compare April 4, 2026 02:42
@starfolkai
Copy link
Copy Markdown

starfolkai bot commented Apr 4, 2026

Drop into this review session: sfk devbox connect pr-206-braintrust-sdk-python-946c --attach

Found 3 issues:

  1. setup_openai_agents() uses current_span, NOOP_SPAN, and init_logger without importing them -- calling this function will raise NameError at runtime. The sibling setup_openai() correctly imports these from braintrust.logger on line 3.

project_name: str | None = None,
) -> bool:
"""Setup Braintrust tracing for the OpenAI Agents SDK."""
if current_span() == NOOP_SPAN:
init_logger(project=project_name or project, api_key=api_key, project_id=project_id)

Compare with the working pattern:

"""Braintrust integration for the OpenAI Python SDK and OpenAI-compatible gateways."""
from braintrust.logger import NOOP_SPAN, current_span, init_logger
from .integration import OpenAIIntegration
from .patchers import wrap_openai

  1. auto_instrument() has no openai_agents parameter and never sets "openai_agents" in its return dict, but the auto-test script asserts results.get("openai_agents") == True. This test will always fail. Additionally, OpenAIAgentsIntegration is not exported from integrations/__init__.py, unlike every other integration.

results = auto_instrument()
assert results.get("openai_agents") == True
assert _has_braintrust_processor()
results2 = auto_instrument()
assert results2.get("openai_agents") == True

from .adk import ADKIntegration
from .agentscope import AgentScopeIntegration
from .agno import AgnoIntegration
from .anthropic import AnthropicIntegration
from .claude_agent_sdk import ClaudeAgentSDKIntegration
from .dspy import DSPyIntegration
from .google_genai import GoogleGenAIIntegration
from .langchain import LangChainIntegration
from .litellm import LiteLLMIntegration
from .openrouter import OpenRouterIntegration
from .pydantic_ai import PydanticAIIntegration
__all__ = [
"ADKIntegration",
"AgentScopeIntegration",
"AgnoIntegration",
"AnthropicIntegration",
"ClaudeAgentSDKIntegration",
"DSPyIntegration",
"GoogleGenAIIntegration",
"LiteLLMIntegration",
"LangChainIntegration",
"OpenRouterIntegration",
"PydanticAIIntegration",
]

  1. Four test classes (TestPatchOpenAI, TestPatchOpenAISpans, TestPatchOpenAIAsyncSpans, TestZAICompatibleOpenAI) were dropped during the migration without being moved to the new integration test files. patch_openai() still exists in oai.py but now has no test coverage. TestZAICompatibleOpenAI was a regression guard for a bug fix (None tool call arguments from GLM-4 models) whose fix is still in the code.

def patch_openai() -> bool:

Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the abhi-refactor-migrate-openai-wrapper-to-integrations branch 2 times, most recently from 62144a7 to 4069970 Compare April 4, 2026 03:44
…tion

Move OpenAI wrapper tests, cassettes, and tracing code from
`wrappers/` into `integrations/openai/`. Split OpenAI Agents SDK
tracing processor into its own `integrations/openai_agents/` package
with a dedicated `test_openai_agents` nox session.

Add new Claude Agent SDK integration under `integrations/` with
subprocess transport-level cassette support.

The old `wrappers/openai.py` now re-exports `BraintrustTracingProcessor`
from the new location for backward compatibility. Test paths in
`noxfile.py` are updated to point at the new integration directories.
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the abhi-refactor-migrate-openai-wrapper-to-integrations branch from 4069970 to 948dcd7 Compare April 5, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant