Anonymous View
Skip to content

refactor(harness): move OpenAI harness into adk/_modules + facade export#432

Merged
declan-scale merged 2 commits into
nextfrom
declan-scale/harness-openai-modules
Jun 23, 2026
Merged

refactor(harness): move OpenAI harness into adk/_modules + facade export#432
declan-scale merged 2 commits into
nextfrom
declan-scale/harness-openai-modules

Conversation

@declan-scale

@declan-scale declan-scale commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Sixth slice of #425. Consolidates the OpenAI harness into the canonical adk/_modules layout and makes it a first-class facade export.

  • Move into _modulesOpenAITurn_modules/_openai_turn.py, the sync tap (convert_openai_to_agentex_events) → _modules/_openai_sync.py, matching every other harness.
  • Back-compat shims kept at providers/_modules/{openai_turn,sync_provider}.py, so existing import paths (tutorials, sync-openai-agents template, services) keep working. The larger Temporal/MCP provider stays under adk.providers.
  • Facade export (Greptile follow-up)OpenAITurn, openai_usage_to_turn_usage, and convert_openai_to_agentex_events are now exported from agentex.lib.adk, parallel to ClaudeCodeTurn / CodexTurn. The new default-openai-agents template (next PR) imports from the package facade rather than a private module path.

Test plan

  • pytest tests/lib/adk/providers/test_openai_turn.py test_openai_activities.py — 27 passed
  • facade + back-compat shim imports verified
  • ruff check on all changed source — clean

Notes

Stacked on #431. Retarget to next after the chain merges.

🤖 Generated with Claude Code

Greptile Summary

This PR moves the OpenAI harness implementation (OpenAITurn, convert_openai_to_agentex_events, openai_usage_to_turn_usage) from providers/_modules/ into the canonical adk/_modules/ layout, matching every other harness (LangGraph, PydanticAI, ClaudeCode, Codex), and exposes the three symbols as first-class exports from agentex.lib.adk.

  • _modules/_openai_turn.py and _modules/_openai_sync.py are lifted verbatim from their old locations; the old files become thin back-compat shims that re-export unchanged.
  • providers/_modules/openai_turn.py now re-exports both OpenAITurn and openai_usage_to_turn_usage (fixing the gap flagged in the previous review), while sync_provider.py re-exports convert_openai_to_agentex_events via the explicit-alias pattern.

Confidence Score: 5/5

Safe to merge — this is a pure structural lift with no logic changes; both back-compat shims are in place and the previous gap (missing openai_usage_to_turn_usage in the shim) is now resolved.

The implementation code is moved verbatim; the facade export and both shims have been verified to expose the full original surface. Tests continue to pass against the new canonical paths and the old shim paths remain importable.

No files require special attention. The two minor style issues in _openai_sync.py (unused counter, inline imports) are pre-existing carry-overs and do not affect correctness.

Important Files Changed

Filename Overview
src/agentex/lib/adk/init.py Adds facade imports and all entries for OpenAITurn, openai_usage_to_turn_usage, and convert_openai_to_agentex_events from the new _modules paths; consistent with ClaudeCode and Codex patterns already in the file.
src/agentex/lib/adk/_modules/_openai_sync.py New canonical home for convert_openai_to_agentex_events and its helpers; code is a faithful lift from sync_provider.py with two minor pre-existing style issues (unused event_count counter, import json inside function branches).
src/agentex/lib/adk/_modules/_openai_turn.py New canonical home for OpenAITurn, openai_usage_to_turn_usage, and _aggregate_usage; clean lift from the old providers/_modules/openai_turn.py with updated intra-package import path.
src/agentex/lib/adk/providers/_modules/openai_turn.py Replaced with a back-compat shim; now correctly re-exports both OpenAITurn and openai_usage_to_turn_usage (addressing the previous review comment), using noqa: F401 to suppress unused-import warnings.
src/agentex/lib/adk/providers/_modules/sync_provider.py Implementation of convert_openai_to_agentex_events removed; re-exported from _openai_sync via the explicit alias pattern for back-compat; SyncStreamingModel deprecation notice updated to the new canonical path.
src/agentex/lib/core/services/adk/providers/openai.py Minor comment housekeeping only — ticket reference stripped from an inline comment; no functional change.
tests/lib/adk/providers/test_openai_turn.py Import paths updated to point at the new canonical module (_modules._openai_turn); test coverage and logic unchanged.
tests/lib/adk/providers/test_openai_activities.py Ticket reference removed from one docstring; no functional or coverage change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    facade["agentex.lib.adk\n(__init__.py)\nFacade export"]

    subgraph NEW ["New canonical locations (_modules)"]
        ot["_modules/_openai_turn.py\nOpenAITurn\nopenai_usage_to_turn_usage\n_aggregate_usage"]
        os["_modules/_openai_sync.py\nconvert_openai_to_agentex_events\n_extract_tool_call_info\n_extract_tool_response_info"]
    end

    subgraph SHIMS ["Back-compat shims (providers/_modules)"]
        shimT["providers/_modules/openai_turn.py\n(re-exports OpenAITurn +\nopenai_usage_to_turn_usage)"]
        shimS["providers/_modules/sync_provider.py\n(re-exports convert_openai_to_agentex_events)"]
    end

    svc["lib/core/services/adk/providers/openai.py\n(OpenAIService)"]
    tests["tests/lib/adk/providers/\ntest_openai_turn.py\ntest_openai_activities.py"]

    facade -->|imports from| ot
    facade -->|imports from| os
    shimT -->|re-exports from| ot
    shimS -->|re-exports from| os
    ot -->|imports from| os
    svc -->|uses| ot
    tests -->|imports directly from| ot
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    facade["agentex.lib.adk\n(__init__.py)\nFacade export"]

    subgraph NEW ["New canonical locations (_modules)"]
        ot["_modules/_openai_turn.py\nOpenAITurn\nopenai_usage_to_turn_usage\n_aggregate_usage"]
        os["_modules/_openai_sync.py\nconvert_openai_to_agentex_events\n_extract_tool_call_info\n_extract_tool_response_info"]
    end

    subgraph SHIMS ["Back-compat shims (providers/_modules)"]
        shimT["providers/_modules/openai_turn.py\n(re-exports OpenAITurn +\nopenai_usage_to_turn_usage)"]
        shimS["providers/_modules/sync_provider.py\n(re-exports convert_openai_to_agentex_events)"]
    end

    svc["lib/core/services/adk/providers/openai.py\n(OpenAIService)"]
    tests["tests/lib/adk/providers/\ntest_openai_turn.py\ntest_openai_activities.py"]

    facade -->|imports from| ot
    facade -->|imports from| os
    shimT -->|re-exports from| ot
    shimS -->|re-exports from| os
    ot -->|imports from| os
    svc -->|uses| ot
    tests -->|imports directly from| ot
Loading

Reviews (12): Last reviewed commit: "fix(harness): sort OpenAI sync imports" | Re-trigger Greptile

@declan-scale

Copy link
Copy Markdown
Contributor Author

@greptile review

Comment thread src/agentex/lib/adk/providers/_modules/openai_turn.py Outdated
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from 0175fb6 to 97a34fa Compare June 23, 2026 15:43
@declan-scale

Copy link
Copy Markdown
Contributor Author

@greptile review

1 similar comment
@declan-scale

Copy link
Copy Markdown
Contributor Author

@greptile review

@declan-scale declan-scale force-pushed the declan-scale/harness-pydantic-consolidation branch from d7367a9 to 97b0418 Compare June 23, 2026 16:51
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from 97a34fa to b01cfcc Compare June 23, 2026 16:51
@declan-scale

Copy link
Copy Markdown
Contributor Author

@greptile review

@declan-scale declan-scale force-pushed the declan-scale/harness-pydantic-consolidation branch from 97b0418 to c7b151c Compare June 23, 2026 19:53
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from b01cfcc to 24d10ab Compare June 23, 2026 19:53
@declan-scale declan-scale force-pushed the declan-scale/harness-pydantic-consolidation branch from c7b151c to 176baf9 Compare June 23, 2026 19:56
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from 24d10ab to c17c9b3 Compare June 23, 2026 19:56
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from c17c9b3 to ee560a1 Compare June 23, 2026 22:04
@declan-scale declan-scale force-pushed the declan-scale/harness-pydantic-consolidation branch from 176baf9 to 1b41f4d Compare June 23, 2026 22:04
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from ee560a1 to fdf6187 Compare June 23, 2026 22:29
@declan-scale declan-scale force-pushed the declan-scale/harness-pydantic-consolidation branch 3 times, most recently from 7448a38 to b30a90b Compare June 23, 2026 23:26
Base automatically changed from declan-scale/harness-pydantic-consolidation to next June 23, 2026 23:33
declan-scale and others added 2 commits June 23, 2026 23:39
… at facade

Promote the OpenAI Turn and sync tap to the canonical adk/_modules layout
(_openai_turn.py, _openai_sync.py), matching every other harness. Leave
back-compat shims at providers/_modules/{openai_turn,sync_provider}.py so
existing import paths keep working; the larger Temporal/MCP provider stays
under adk.providers.

Export OpenAITurn, openai_usage_to_turn_usage and convert_openai_to_agentex_events
from agentex.lib.adk so the OpenAI harness is a first-class facade citizen like
ClaudeCodeTurn / CodexTurn (fixes Greptile follow-up: templates can import from
the package facade instead of a private module path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@declan-scale declan-scale force-pushed the declan-scale/harness-openai-modules branch from 4ea74ac to 1efd8dc Compare June 23, 2026 23:40
@declan-scale declan-scale merged commit 58bdb16 into next Jun 23, 2026
55 checks passed
@declan-scale declan-scale deleted the declan-scale/harness-openai-modules branch June 23, 2026 23:46
@stainless-app stainless-app Bot mentioned this pull request Jun 23, 2026
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.

2 participants