Skip to content

Commit a7cdbc0

Browse files
jeffdupontclaude
andauthored
feat(AIC-3687)!: rename create_openai_agent_handler to create_openai_agents_handler (#225)
Jira: [AIC-3687](https://launchdarkly.atlassian.net/browse/AIC-3687) ## What changed - `launchdarkly_ai_openai_agents.create_openai_agent_handler` is renamed `create_openai_agents_handler`, so it matches the other agents packages (`create_claude_agents_handler`, `create_litellm_agents_handler`). The non-reporting internal `_create_openai_agent_handler` is renamed `_create_openai_agents_handler` to match. - Every reference is updated: package code (`__init__.py`, `handler.py`, `graph.py`), tests, `README.md`, `AGENTS.md`, `examples/register.py`, `packages/client/README.md`, `packages/openai-agents/README.md` and `agents.md`. - No deprecated alias. - The `$ld:ai:sdk:usage` ID `openai-agents.createOpenAIAgentHandler` is **unchanged**, as the monorepo spec requires, so usage telemetry stays continuous. Only the Python function name changes. - API report regenerated with `make api-report`. **Pre-1.0 rename:** the old name is no longer importable. Nothing has shipped as 1.0, so there is no compatibility promise to keep. The `!` only gives the 0.x minor bump. The monorepo API-surface lists are updated in a companion ai-sdks-monorepo PR. ## Testing - `make api-report` and `make api-report-check`: pass - `make lint`, `make format-check`, `make typecheck`: pass - `uv run pytest packages/openai-agents`: 192 passed - `make test`: 3631 passed, 2 failed. The 2 failures (`packages/client/tests/test_lifecycle.py::TestInitClientSDKKeyPath::test_uses_options_sdk_key_over_env_var` and `::test_retries_after_a_failed_init_instead_of_replaying_it`) fail the same way on an untouched `origin/main` checkout in the same location. They pick up staging URIs from a local `.env`, so they are a local environment issue, not caused by this change. - `git grep create_openai_agent_handler` (excluding CHANGELOGs): no matches. `git grep -F openai-agents.createOpenAIAgentHandler`: still in `handler.py` and `tests/test_sdk_usage.py`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) [AIC-3687]: https://launchdarkly.atlassian.net/browse/AIC-3687?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Breaking rename** of the OpenAI agents factory from `create_openai_agent_handler` to **`create_openai_agents_handler`**, aligning with `create_claude_agents_handler` and other `*_agents_handler` packages. The internal non-reporting helper is renamed to `_create_openai_agents_handler` as well. > > The public export (`__init__.py`), `handler.py`, `graph.py`, regenerated API report, examples, and all README/agent docs now use the new name. **No deprecated alias** — callers must update imports. > > The `$ld:ai:sdk:usage` event id `openai-agents.createOpenAIAgentHandler` is **unchanged** so usage metrics stay continuous; only the Python symbol changes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1037715. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 11f2c0b commit a7cdbc0

12 files changed

Lines changed: 115 additions & 111 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ Each handler package must export a **factory function** that:
482482
- Initializes any provider-specific resources.
483483
- Returns the handler callable with `provides_for` attached via `create_handler`.
484484

485-
The naming convention is `create_<provider>_handler()`. For example: `create_claude_agents_handler()`, `create_openai_agent_handler()`.
485+
The naming convention is `create_<provider>_handler()`. For example: `create_claude_agents_handler()`, `create_openai_agents_handler()`.
486486

487487
**Always use `create_handler` to build and return the handler.**
488488

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Returns a `ConfigInstance` with `.invoke(user_input, context, variables?)` and `
183183
import asyncio
184184
from launchdarkly_ai_server import config, create_handler, shutdown
185185
from launchdarkly_ai_openai_messages import create_openai_messages_handler
186-
from launchdarkly_ai_openai_agents import create_openai_agent_handler
186+
from launchdarkly_ai_openai_agents import create_openai_agents_handler
187187
from launchdarkly_ai_claude_agents import create_claude_agents_handler
188188
from launchdarkly_ai_claude_messages import create_claude_messages_handler
189189

@@ -208,7 +208,7 @@ router = config(
208208
tool_handlers={"search": lambda q: "..."},
209209
handler=[
210210
create_openai_messages_handler(),
211-
create_openai_agent_handler(),
211+
create_openai_agents_handler(),
212212
create_claude_agents_handler(),
213213
create_claude_messages_handler(),
214214
],
@@ -457,10 +457,10 @@ You can call `register()` more than once to add handlers or tools incrementally.
457457
```python
458458
from launchdarkly_ai_server import Registry
459459
from launchdarkly_ai_openai_messages import create_openai_messages_handler
460-
from launchdarkly_ai_openai_agents import create_openai_agent_handler
460+
from launchdarkly_ai_openai_agents import create_openai_agents_handler
461461

462462
openai_registry = Registry(
463-
handlers=[create_openai_messages_handler(), create_openai_agent_handler()],
463+
handlers=[create_openai_messages_handler(), create_openai_agents_handler()],
464464
tools={"get-prefs": get_preferences_fn},
465465
)
466466
```

‎examples/register.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
from launchdarkly_ai_claude_messages import create_claude_messages_handler
2020
from launchdarkly_ai_langchain_agents import create_langchain_agents_handler
2121
from launchdarkly_ai_langchain_messages import create_langchain_messages_handler
22-
from launchdarkly_ai_openai_agents import create_openai_agent_handler
22+
from launchdarkly_ai_openai_agents import create_openai_agents_handler
2323
from launchdarkly_ai_openai_messages import create_openai_messages_handler
2424
from launchdarkly_ai_server import global_registry
2525
from launchdarkly_ai_typesafe import create_typesafe_handler
2626

2727
global_registry.register(
2828
handlers=[
2929
create_openai_messages_handler(),
30-
create_openai_agent_handler(),
30+
create_openai_agents_handler(),
3131
create_claude_agents_handler(),
3232
create_claude_messages_handler(),
3333
create_langchain_messages_handler(),

‎packages/client/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ The primary entry point for AI config invocations. Accepts either a single handl
314314
import asyncio
315315
from launchdarkly_ai_server import config, shutdown
316316
from launchdarkly_ai_openai_messages import create_openai_messages_handler
317-
from launchdarkly_ai_openai_agents import create_openai_agent_handler
317+
from launchdarkly_ai_openai_agents import create_openai_agents_handler
318318
from launchdarkly_ai_claude_agents import create_claude_agents_handler
319319

320320
# Single handler — must match the flag variation's provider+mode, or raises.
@@ -339,7 +339,7 @@ async def main():
339339
tool_handlers={"search": search_fn},
340340
handler=[
341341
create_openai_messages_handler(), # provides_for: ["OpenAI", "messages"]
342-
create_openai_agent_handler(), # provides_for: ["OpenAI", "agent"]
342+
create_openai_agents_handler(), # provides_for: ["OpenAI", "agent"]
343343
create_claude_agents_handler(), # provides_for: ["Anthropic", "agent"]
344344
],
345345
)

‎packages/openai-agents/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Set `OPENAI_API_KEY` in your environment (the OpenAI SDK reads it automatically)
1919
```python
2020
import asyncio
2121
from launchdarkly_ai_server import config, shutdown
22-
from launchdarkly_ai_openai_agents import create_openai_agent_handler
22+
from launchdarkly_ai_openai_agents import create_openai_agents_handler
2323

2424
async def main():
2525
result = await config(
2626
key="my-ai-config-flag",
27-
handler=create_openai_agent_handler(),
27+
handler=create_openai_agents_handler(),
2828
tool_handlers={"search": lambda q: "..."},
2929
).invoke("Summarize today's changelog", {"kind": "user", "key": "user-123"})
3030

@@ -60,7 +60,7 @@ asyncio.run(main())
6060

6161
### Agent graphs — `openai_graph()`
6262

63-
Runs a LaunchDarkly agent graph with the OpenAI agent handler pre-bound. Equivalent to calling the base `graph()` with `handlers=[create_openai_agent_handler()]`. See the [core client docs](https://github.com/launchdarkly/python-ai-sdk/blob/main/packages/client/README.md#graphkey-options) for the full `graph()` API.
63+
Runs a LaunchDarkly agent graph with the OpenAI agent handler pre-bound. Equivalent to calling the base `graph()` with `handlers=[create_openai_agents_handler()]`. See the [core client docs](https://github.com/launchdarkly/python-ai-sdk/blob/main/packages/client/README.md#graphkey-options) for the full `graph()` API.
6464

6565
```python
6666
import asyncio

‎packages/openai-agents/agents.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ That means the LaunchDarkly flag variation must have `provider.name == "OpenAI"`
3939

4040
```python
4141
# Factory — returns a ProviderHandler with provides_for attached
42-
def create_openai_agent_handler() -> ProviderHandler: ...
42+
def create_openai_agents_handler() -> ProviderHandler: ...
4343

44-
# Convenience wrapper — equivalent to config(key=config_key, handler=create_openai_agent_handler()).invoke(user_input, context)
44+
# Convenience wrapper — equivalent to config(key=config_key, handler=create_openai_agents_handler()).invoke(user_input, context)
4545
def openai_agents(config_key: str, user_input: str, context: dict, **kwargs) -> ProviderResponse: ...
4646

4747
# Graph convenience wrapper
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Public API of launchdarkly_ai_openai_agents. Generated by `make api-report`; do not edit.
22
build_output_type(output_format: dict[str, Any] | None) -> dict[str, Any] | None
3-
create_openai_agent_handler(*, capture_content: bool | None = None) -> ProviderHandler
3+
create_openai_agents_handler(*, capture_content: bool | None = None) -> ProviderHandler
44
openai_agents(config_key: str, user_input: str, context: LDContext, **kwargs: Any) -> Any
55
openai_graph(key: str, **options: Any) -> Any
66
to_openai_agents(def_promise: Any, opts: dict[str, Any] | None = None) -> Any

‎packages/openai-agents/src/launchdarkly_ai_openai_agents/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from . import native_graph # noqa: F401
99
from ._version import PACKAGE_NAME, __version__
1010
from .graph import openai_graph
11-
from .handler import create_openai_agent_handler, openai_agents
11+
from .handler import create_openai_agents_handler, openai_agents
1212
from .native_graph import to_openai_agents
1313
from .utils import build_output_type
1414

1515
__all__ = [
1616
"build_output_type",
17-
"create_openai_agent_handler",
17+
"create_openai_agents_handler",
1818
"openai_agents",
1919
"openai_graph",
2020
"to_openai_agents",

‎packages/openai-agents/src/launchdarkly_ai_openai_agents/graph.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Any
66

7-
from launchdarkly_ai_openai_agents.handler import _create_openai_agent_handler
7+
from launchdarkly_ai_openai_agents.handler import _create_openai_agents_handler
88
from launchdarkly_ai_server import _graph, report_usage
99

1010
from ._version import PACKAGE_NAME, __version__
@@ -14,8 +14,8 @@ def openai_graph(key: str, **options: Any) -> Any:
1414
"""
1515
Runs an agent graph with the OpenAI agent handler pre-bound.
1616
17-
Equivalent to ``graph(key, handlers=[create_openai_agent_handler()], **options)``.
17+
Equivalent to ``graph(key, handlers=[create_openai_agents_handler()], **options)``.
1818
Use the base ``graph()`` directly for multi-provider graphs.
1919
"""
2020
report_usage("openai-agents.openaiGraph", PACKAGE_NAME, __version__)
21-
return _graph(key, handlers=[_create_openai_agent_handler()], **options)
21+
return _graph(key, handlers=[_create_openai_agents_handler()], **options)

‎packages/openai-agents/src/launchdarkly_ai_openai_agents/handler.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def _usage_from_error(error: BaseException) -> SpanUsage | None:
646646
return to_span_usage(usage)
647647

648648

649-
def create_openai_agent_handler(
649+
def create_openai_agents_handler(
650650
*, capture_content: bool | None = None
651651
) -> ProviderHandler:
652652
"""Creates a ``ProviderHandler`` for OpenAI via the openai-agents SDK.
@@ -658,13 +658,13 @@ def create_openai_agent_handler(
658658
models, token counts, timings and tool names, until capture is turned on.
659659
"""
660660
report_usage("openai-agents.createOpenAIAgentHandler", PACKAGE_NAME, __version__)
661-
return _create_openai_agent_handler(capture_content=capture_content)
661+
return _create_openai_agents_handler(capture_content=capture_content)
662662

663663

664-
def _create_openai_agent_handler(
664+
def _create_openai_agents_handler(
665665
*, capture_content: bool | None = None
666666
) -> ProviderHandler:
667-
"""Non-reporting :func:`create_openai_agent_handler`, used by this package's wrappers."""
667+
"""Non-reporting :func:`create_openai_agents_handler`, used by this package's wrappers."""
668668
content_override = capture_content
669669

670670
async def _call_impl(
@@ -943,6 +943,6 @@ def openai_agents(
943943
capture_content = kwargs.pop("capture_content", None)
944944
return _config(
945945
key=config_key,
946-
handler=_create_openai_agent_handler(capture_content=capture_content),
946+
handler=_create_openai_agents_handler(capture_content=capture_content),
947947
**kwargs,
948948
).invoke(user_input, context, variables=variables)

0 commit comments

Comments
 (0)