Skip to content

Conversation

tconley1428
Copy link
Contributor

@tconley1428 tconley1428 commented Jun 12, 2025

What was changed

Added an experimental contrib module to provide compatibility with the OpenAI Agents SDK.

Why?

To facilitate durable execution for applications built with the OpenAI Agents SDK

Checklist

  1. Closes

  2. How was this tested:
    Tests provided in tests/contrib/test_openai.py

  3. Any docs updates needed?
    README provided. Further updates to the documentation are on hold while this code remains experimental.



@contextmanager
def set_open_ai_agent_temporal_overrides(**kwargs):

Choose a reason for hiding this comment

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

If possible, let's just take typed, listed keyword args for type safety and self-documentability for any args we know about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right, but it will take some time. Given the urgency concerns, let's leave that for another version.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also agree that it would be good to do this. The SDK does already have many overloads repeating large sets of arguments; would be good to do this in a future PR.

**kwargs: Additional arguments to pass to the TemporalOpenAIRunner constructor.
These arguments are forwarded to workflow.execute_activity_method when
executing model calls. Common options include:
- start_to_close_timeout: Maximum time for the activity to complete

Choose a reason for hiding this comment

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

nit: let's name this something like model_call_start_to_close_timeout so it's clear what these apply to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would get a bit unwieldy applying to all the different kwargs, I think we'd be better off documenting them as a set

Copy link

@drewhoskins-temporal drewhoskins-temporal Jun 19, 2025

Choose a reason for hiding this comment

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

The name is too ambiguous as-is. We definitely need to do something here, soon. Johann and I were brainstorming approaches.

search_results = await self._perform_searches(search_plan)
report = await self._write_report(query, search_results)

print("\n\n=====REPORT=====\n\n")
Copy link

@drewhoskins-temporal drewhoskins-temporal Jun 18, 2025

Choose a reason for hiding this comment

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

use workflow.logger.info() instead of print, to avoid redudant prints upon replay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the effort is more to generalize taking a class like this into temporal. While it is true that the prints might not show up if you are running the workflow on a worker elsewhere, I'm hesitant to pull in a temporal dependency in this file just for logging. The print isn't really important since the result is what matters

Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

Nice, LGTM!

@tconley1428 tconley1428 merged commit 53d9ace into main Jun 19, 2025
34 of 37 checks passed
@tconley1428 tconley1428 deleted the openai-agents-tests branch June 19, 2025 00:04
tconley1428 added a commit that referenced this pull request Aug 28, 2025
* 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]>
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.

7 participants