Skip to content

Import python/openai_agents from sdk-python with full history (pilot plugin) - #2

Merged
brianstrauch merged 107 commits into
mainfrom
import/python-openai-agents
Sep 3, 2026
Merged

brianstrauch merged 107 commits into
mainfrom
import/python-openai-agents

Conversation

@DABH

@DABH DABH commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Imports temporalio.contrib.openai_agents from temporalio/sdk-python@d0e075c1 (2026-09-01 main) into python/openai_agents/ with its complete git history, then adds the packaging, metadata and test scaffolding that make it the standalone distribution temporalio-openai-agents (version 1.0.0rc1, GA maturity, allow-final = false until the SDK cutover). Nothing is removed from sdk-python.

Stacked on #1 (base branch bootstrap); retarget to main once #1 merges.

History

  • 101 upstream commits, 18 author identities, single root OpenAI agents support (#898) (2025-06-18). Every commit carries a Migrated-From: temporalio/sdk-python@<sha> trailer, #NNN references point at temporalio/sdk-python#NNN, no upstream tags imported.
  • git log --follow and git blame on any imported file reach the original authors and dates; the import is recorded in scripts/migrate/IMPORTS.md.
  • Produced by the committed scripts/migrate/extract-sdk-python.sh; re-running it against the same upstream state is byte-identical (verified: same tip SHA across three runs), so a later re-sync is a plain git merge of new upstream commits.
  • Merge this PR with "Create a merge commit". Squash or rebase would destroy the history.

Adaptation (three commits on top of the merge; imported code is untouched except the README)

  • pyproject.toml (uv_build, module-name = "temporalio.contrib.openai_agents", dependencies declared exactly as imported, cooldown with temporalio exempted), plugin.toml, two-line Makefile, LICENSE -> ../../LICENSE, uv.lock, py.typed.
  • tests/ mirrors the upstream tree (tests/contrib/openai_agents/...) so re-syncs apply cleanly; pruned vendored conftest.py with offline record/replay and the provenance guard; package markers.
  • README: install section with the pre-cutover warning and three sibling links made absolute (PyPI renders this file). This is the only imported file edited (TRANSITION(sdk-cutover)).

Verified locally

  • make sync && make lint: ruff, pyright, mypy, basedpyright, pydocstyle all clean on the imported code.
  • make build + check_wheel.py + isolated smoke of wheel and sdist: pass (wheel ships no parent __init__.py, LICENSE and py.typed present; provenance guard passes, SDK overlap reported as the expected pre-cutover warning).
  • Offline test suite with no OPENAI_API_KEY: 214 passed, 3 skipped, 13 failed. The 13 are exactly the parametrized arms that call the OpenAI API (test_*[False], test_chat_completions_model, three test_mcp_server arms); they need cassettes recorded once with a real key (OPENAI_API_KEY=... make record), after which CI runs fully offline. Everything else, including all 7 replay-history tests, passes.

Left for a human

  1. Record the cassettes: cd python/openai_agents && OPENAI_API_KEY=<real key> make record, review tests/contrib/openai_agents/cassettes/ for secrets (the conventions check also scans), commit. test_file_search_tool[False] references a vector store in a specific OpenAI account, so record from that account or add it to OFFLINE_SKIPS.
  2. Admin: grant @temporalio/ai-sdk repo access; create environments testpypi/pypi with tag policy python/*/v*; TestPyPI and PyPI pending trusted publishers for temporalio-openai-agents (workflow release-python.yml).
  3. Rehearse the release: tag python/openai_agents/v1.0.0rc1 after merge.

tconley1428 and others added 30 commits June 18, 2025 17:04
* Added openai_agents.

* added tools and trace interceptor.

* Lint error fixes

* Lint error fixes

* Missing docstrings added.

* Fixed tool serialization.

* Initial test implementation

* Intercept test calls to LLM

* Move to optional dependency

* Linting

* Fixing build errors

* Fixing build errors

* Fixing typo

* Fake API key for test, skip below 3.11

* Tools test

* Move activity to a method to allow model customization without monkey patch

* Change overrides to context manager

* Research workflow test

* Customer service and agents as tools tests. These will currently fail without a change to type deserialization of agent responses

* Fix up some imports

* Remove unneeded print

* Doc string improvement

* Execute inside sandbox

* 3.9 lint error

* Add activity configuration to openai overrides and activity_as_tool

* Update docstrings

* Updating tests

* Add experimental warnings

* Remove runtime warnings

* Test required import for build error

* Fix import

* Update open_ai_data_converter.py

* Remove required import

* Simplify custom data converter

* Replace rebuild

* Add passthrough type namespaces to data converter

* Check activity count in customer_service test

* cleanup dataconverter imports + doc build errors

* add documentation

* Fix model rebuild

* update for OpenAI Agents SDK release 0.0.19

* lint fixes

* fixed and elaborated on README

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Spencer Judge <[email protected]>

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Spencer Judge <[email protected]>

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Dan Davison <[email protected]>

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Dan Davison <[email protected]>

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Dan Davison <[email protected]>

* Update temporalio/contrib/openai_agents/README.md

Co-authored-by: Dan Davison <[email protected]>

* readme updates

* Addressing PR feedback, mostly some new test validation

* PR cleanup from feedback

* Remove change from irrelevant file

* PR cleanup

* Add custom message for tool output failure

* Remove commented code and unneeded sandbox statement

---------

Co-authored-by: Maxim Fateev <[email protected]>
Co-authored-by: Johann Schleier-Smith <[email protected]>
Co-authored-by: Johann Schleier-Smith <[email protected]>
Co-authored-by: Spencer Judge <[email protected]>
Co-authored-by: Dan Davison <[email protected]>
Migrated-From: temporalio/sdk-python@53d9ace
* Update versions for release

* Remove rc from release

* Add Slack link to OpenAI README

---------

Co-authored-by: Dan Davison <[email protected]>
Migrated-From: temporalio/sdk-python@9f62668
…ython#918)

* Fixing issues with openai integration on python 3.9

* Restrict eval_type to python 3.9

Migrated-From: temporalio/sdk-python@40f1624
…-python#917)

* Adding named params to openai activity configurations

* Remove a few unused imports

* Move model parameters into an object, remove activity id

* Refer argument docs to , early check timeout

* Removing example usage because of pydoctor errors

Migrated-From: temporalio/sdk-python@4cf0697
…ralio/sdk-python#922)

* Adding an end to end test which uses an openai service account

* Lint

* Add trace intercepter

* Include data converter

Migrated-From: temporalio/sdk-python@29599e5
…io/sdk-python#920)

* Experimental CI entry to run tests with latest dependencies

* Fix upgrade command

* Further discriminate log names

* Remove locked from matrix

* Fixing problem with updated openai dependency

* Lint

* Move latest deps test to separate job

* Fix openai test break

* Pydantic validation fails anyway, so remove type ingore

* CI cleanup

Migrated-From: temporalio/sdk-python@8fc55e7
* Adding tests for guardrail samples

* Fix lint

* Remove | syntax

Migrated-From: temporalio/sdk-python@5a95f8e
* Processing activity tool input through the function schema's pydantic model

* Fix issues with multiple arguments

* Undo prompt change

* Add explicit application error for invalid json tool input

* Change error return

* Change error base class

* Fix linting

* Update core

Migrated-From: temporalio/sdk-python@61d5072
…/sdk-python#930)

* Adding replay and end to end tests for all existing tests

* Experimental CI entry to run tests with latest dependencies (temporalio/sdk-python#920)

* Experimental CI entry to run tests with latest dependencies

* Fix upgrade command

* Further discriminate log names

* Remove locked from matrix

* Fixing problem with updated openai dependency

* Lint

* Move latest deps test to separate job

* Fix openai test break

* Pydantic validation fails anyway, so remove type ingore

* CI cleanup

* Remove history write

* Linting

* Remove history output

* Configure the data converter

* Linting

* Fix merge error

Migrated-From: temporalio/sdk-python@47027fc
* Don't create fake parent span, use actual processor base class

* Remove print

Migrated-From: temporalio/sdk-python@83d2ae4
* Toying with context input to tools

* Doc update

* Remove import

Migrated-From: temporalio/sdk-python@ecfb72f
* Set default model activity timeout to 60s

* Make model activity params optional

Migrated-From: temporalio/sdk-python@6fbc4c5
* WIP module layout overhaul

* WIP. Mostly test model changes

* Finish decorator definition and docstrings

* Also tag activity_as_tool as a temporal tool

* Remove temporal only tool restriction

* Rearrange imports

* Fix 3.9 typing

* Addressing comments

* Updating readme

* Remove ellipsis

* Fix linting

* Reduce research workflow quantity, extend timeout

Migrated-From: temporalio/sdk-python@61af3ea
* Remove wrapping function decorator

* Linting

Migrated-From: temporalio/sdk-python@3a27fe8
…ython#968)

* Support for method activities conversion into tools

* Fix test

Migrated-From: temporalio/sdk-python@c37c69f
* Fixing tracing issues. Propagate span parentage, remove startActivity

* Remove traceback

* Add start traces with correct durations

* Add tracing test

* Remove cast

* Remove flaky test check

Migrated-From: temporalio/sdk-python@60f67d9
* Fix type errors

* Do not make drive-by check for other type errors

Migrated-From: temporalio/sdk-python@7c57a76
* Initial rough framework for plugins

* Ensure plugin modification happen before any other initialization

* Openai Agents plugin PoC

* Remove extra import/exports

* Format

* Use local tuner for type inference

* Add docstrings and fix merge issues

* Remove tests duplicated by merge

* Fix tests

* Rename plugin + a few fixes

* Lint

Migrated-From: temporalio/sdk-python@0f3c577
* Update agents sdk dependency to latest. Add test for newly functional serialization scenarios

* Linting

* Attempt lint fix, it didn't happen locally

* Attempt lint fix

* Test cleanup

Migrated-From: temporalio/sdk-python@9e7dc7a
…#982)

* Add exception catching logic to model activity

* Fix timeout

* Retry after + fixes

* Linting

* Only set timeouts for default model provider

Migrated-From: temporalio/sdk-python@fe82b07
…dk-python#985)

* Add argument validation for the types of provided tools

* Specifically check if it is a callable, as Union isn't supported in isinstance

* Fix type check with typing.get_args

* Fix check

Migrated-From: temporalio/sdk-python@8b727e5
* Add test for chat completions model

* lint

Migrated-From: temporalio/sdk-python@f815886
* Add heartbeat test and fix bug

* Reduce intervals for speed

* Linting

* Skip new test on time skipping server

* Update timings

Migrated-From: temporalio/sdk-python@d863f5c
* Making summary generation more robust, generally summarize as the last message type input

* Remove assert

* Remove unused imports

* Extend timeout for test stability

* Unit test summary, explicitly handle some edge cases

* Small fix

Migrated-From: temporalio/sdk-python@79f2900

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The offline suite is incomplete and the imported runtime has unresolved sandbox, tracing, caching, and concurrency defects.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Imports the OpenAI Agents integration from the Python SDK with preserved history and packages it as an independently installable plugin.

Changes:

  • Adds the temporalio-openai-agents package and migration record.
  • Adds standalone metadata, dependency locking, build configuration, and transitional overlap safeguards.
  • Migrates integration tests, replay histories, offline-test configuration, and provenance checks.
File summaries
File Description
scripts/migrate/IMPORTS.md Records the history-preserving import.
python/_template/tests/helpers/plugin_meta.py Updates Python 3.10 TOML compatibility handling.
python/openai_agents/LICENSE Links the repository license.
python/openai_agents/Makefile Uses shared Python plugin targets.
python/openai_agents/README.md Documents usage and transition constraints.
python/openai_agents/plugin.toml Defines plugin, CI, and release metadata.
python/openai_agents/pyproject.toml Configures packaging, dependencies, and tooling.
python/openai_agents/uv.lock Locks plugin dependencies.
python/openai_agents/src/temporalio/contrib/openai_agents/__init__.py Exposes the public plugin API.
python/openai_agents/src/temporalio/contrib/openai_agents/_errors.py Defines workflow errors.
python/openai_agents/src/temporalio/contrib/openai_agents/_heartbeat_decorator.py Adds automatic activity heartbeats.
python/openai_agents/src/temporalio/contrib/openai_agents/_invoke_model_activity.py Implements model activities and streaming.
python/openai_agents/src/temporalio/contrib/openai_agents/_mcp.py Implements durable MCP adapters.
python/openai_agents/src/temporalio/contrib/openai_agents/_model_parameters.py Defines model activity settings.
python/openai_agents/src/temporalio/contrib/openai_agents/_openai_runner.py Adapts Agents runs for workflows.
python/openai_agents/src/temporalio/contrib/openai_agents/_otel_trace_interceptor.py Propagates OpenTelemetry context.
python/openai_agents/src/temporalio/contrib/openai_agents/_temporal_model_stub.py Routes model calls through activities.
python/openai_agents/src/temporalio/contrib/openai_agents/_temporal_openai_agents.py Configures the Temporal plugin.
python/openai_agents/src/temporalio/contrib/openai_agents/_temporal_trace_provider.py Provides replay-aware tracing.
python/openai_agents/src/temporalio/contrib/openai_agents/_temporal_worker_env_ref.py Resolves allowlisted worker secrets.
python/openai_agents/src/temporalio/contrib/openai_agents/_trace_interceptor.py Propagates Agents trace context.
python/openai_agents/src/temporalio/contrib/openai_agents/py.typed Marks the package as typed.
python/openai_agents/src/temporalio/contrib/openai_agents/testing.py Adds plugin testing utilities.
python/openai_agents/src/temporalio/contrib/openai_agents/workflow.py Exposes workflow-side adapters.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/__init__.py Defines the sandbox package.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/_sandbox_client_provider.py Registers sandbox activities.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/_temporal_activity_models.py Defines sandbox payload models.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/_temporal_sandbox_client.py Implements the workflow sandbox client.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/_temporal_sandbox_session.py Routes sandbox session operations.
python/openai_agents/src/temporalio/contrib/openai_agents/sandbox/_temporal_worker_env_value.py Resolves sandbox environment values.
python/openai_agents/tests/__init__.py Pins the Temporal test server.
python/openai_agents/tests/conftest.py Configures offline tests and provenance checks.
python/openai_agents/tests/contrib/__init__.py Preserves the upstream test package layout.
python/openai_agents/tests/contrib/openai_agents/__init__.py Defines the integration test package.
python/openai_agents/tests/contrib/openai_agents/test_openai.py Covers core integration behavior.
python/openai_agents/tests/contrib/openai_agents/test_openai_replay.py Verifies replay compatibility.
python/openai_agents/tests/contrib/openai_agents/test_openai_sandbox.py Covers sandbox integration.
python/openai_agents/tests/contrib/openai_agents/test_openai_sandbox_worker_env_value.py Covers sandbox secret resolution.
python/openai_agents/tests/contrib/openai_agents/test_openai_streaming.py Covers streaming behavior.
python/openai_agents/tests/contrib/openai_agents/test_openai_tool_secrets.py Covers hosted-tool secrets.
python/openai_agents/tests/contrib/openai_agents/test_openai_tracing.py Covers tracing integration.
python/openai_agents/tests/contrib/openai_agents/research_agents/__init__.py Defines the research fixture package.
python/openai_agents/tests/contrib/openai_agents/research_agents/planner_agent.py Provides a planner fixture.
python/openai_agents/tests/contrib/openai_agents/research_agents/printer.py Provides research progress rendering.
python/openai_agents/tests/contrib/openai_agents/research_agents/research_manager.py Orchestrates research fixtures.
python/openai_agents/tests/contrib/openai_agents/research_agents/search_agent.py Provides a search fixture.
python/openai_agents/tests/contrib/openai_agents/research_agents/writer_agent.py Provides a report-writing fixture.
python/openai_agents/tests/contrib/openai_agents/histories/agents-as-tools-workflow-history.json Adds an agent-tools replay history.
python/openai_agents/tests/contrib/openai_agents/histories/customer-service-workflow-history.json Adds a customer-service replay history.
python/openai_agents/tests/contrib/openai_agents/histories/hello-workflow-history.json Adds a basic replay history.
python/openai_agents/tests/contrib/openai_agents/histories/input-guardrail-workflow-history.json Adds an input-guardrail history.
python/openai_agents/tests/contrib/openai_agents/histories/output-guardrail-workflow-history.json Adds an output-guardrail history.
python/openai_agents/tests/contrib/openai_agents/histories/research-workflow-history.json Adds a research replay history.
python/openai_agents/tests/contrib/openai_agents/histories/tools-workflow-history.json Adds a tools replay history.
python/openai_agents/tests/helpers/__init__.py Provides shared worker helpers.
python/openai_agents/tests/helpers/nexus.py Provides Nexus test naming.
python/openai_agents/tests/helpers/plugin_meta.py Loads plugin metadata in tests.
python/openai_agents/tests/helpers/provenance.py Validates installed-package provenance.
python/openai_agents/tests/test_installed_matches_source.py Compares installed and source files.
Review details
  • Files reviewed: 52/59 changed files
  • Comments generated: 9
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/openai_agents/tests/conftest.py Resolved
@DABH
DABH force-pushed the import/python-openai-agents branch 2 times, most recently from e6c8b26 to 2c92faa Compare September 2, 2026 17:46
Comment thread python/openai_agents/LICENSE Resolved
Comment thread python/openai_agents/plugin.toml Resolved
Comment thread python/openai_agents/plugin.toml Resolved
Comment thread python/openai_agents/plugin.toml Resolved
@DABH
DABH force-pushed the import/python-openai-agents branch 2 times, most recently from 690fb37 to fe3aea6 Compare September 2, 2026 23:49
@DABH
DABH force-pushed the import/python-openai-agents branch from fe3aea6 to aeca25f Compare September 2, 2026 23:52
Base automatically changed from bootstrap to main September 3, 2026 17:55
@brianstrauch
brianstrauch requested a review from a team as a code owner September 3, 2026 17:55
@brianstrauch
brianstrauch force-pushed the import/python-openai-agents branch from aeca25f to e22cacf Compare September 3, 2026 17:55
brianstrauch and others added 5 commits September 3, 2026 12:32
Standalone distribution `temporalio-openai-agents` 1.0.0rc1 built with uv_build
into the temporalio.contrib namespace (no parent __init__.py), depending on
temporalio[opentelemetry,pydantic] 1.32+, openai-agents 0.19.x, openai, mcp,
pydantic and typing-extensions exactly as the code imports them. plugin.toml
carries the metadata CI and the release pipeline read; the LICENSE is a symlink
to the root license; tests/ mirrors the upstream tree with package markers, the
pruned conftest (offline record/replay, provenance guard) and vendored helpers.

TRANSITION(sdk-cutover): allow-final stays false and the floor stays 1.32.0
until the SDK release that no longer bundles this module.
PyPI renders this file, so the three links to the sibling workflow_streams
README become absolute sdk-python URLs, and an install section with the
pre-cutover warning is added at the top. This is the only imported file the
adaptation touches; expect a trivial conflict on re-sync if upstream edits
these lines.
… plugin.toml

The conftest and helpers are byte-identical to python/_template again. The
plugin's offline settings are data in plugin.toml [offline]: the placeholder
OPENAI_API_KEY for replay and the skips for the real-API arms of the upstream
tests (policy: no real provider key anywhere), whose offline twins still run.
LICENSE is a committed copy of the root license, kept identical by the
conventions check.
@brianstrauch
brianstrauch force-pushed the import/python-openai-agents branch from e22cacf to cfb19fa Compare September 3, 2026 19:33
@brianstrauch
brianstrauch merged commit d925323 into main Sep 3, 2026
17 checks passed
@brianstrauch
brianstrauch deleted the import/python-openai-agents branch September 3, 2026 20:00
pingu1m added a commit to pingu1m/ai-integrations that referenced this pull request Oct 31, 2026
…n parallel sub-agents

All model calls share one Activity type and use the SDK sequence id, and
replay compares only the Activity id and type, never the input. When a
change reordered two parallel sub-agents' model calls, replay passed and
each sub-agent silently received the other's recorded answer.

Give a model call dispatched while another model call of the same run is
in flight an Activity id built from the call it answers
(deepagents.model:<hash>:<turn>, the hash covering the agent name and the
whole non-system transcript in dumpd form, with a temporalio#2/#3 suffix for
repeats). Sequential calls keep the sequence ids, as does any call whose
identity cannot be built, and a caller-set activity_id is left alone.
sdk-core's own id check then fails the replay with a nondeterminism error
instead of crossing the results. Gated by workflow.patched
("deepagents.parallel-model-call-ids"), asked at a run's first overlapping
model call, so runs that never overlap model calls record no marker and
their histories do not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sohom-cs added a commit to sohom-cs/ai-integrations that referenced this pull request Nov 2, 2026
… parallel

Two tests over three runs: run k makes k + 1 identical task calls, and
every Activity returns a new value. In the first, the calls go one after
another: the completed calls, including the "temporalio#1" and "temporalio#2" occurrences,
come back from the cache in order, and each later run schedules an
Activity for its extra call only. In the second, the calls start
together: they are scheduled before any completes, get separate
results, and keep their places after continue-as-new. Every run's
history is replayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

history-import History import/re-sync from an SDK repo: merge with a merge commit, never squash

Projects

None yet

Development

Successfully merging this pull request may close these issues.