Skip to content

💥 BREAKING CHANGE - Lazy passthrough for sys.modules and OpenAI converter/sandbox improvements #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2025

Conversation

cretz
Copy link
Member

@cretz cretz commented Jul 2, 2025

What was changed

  • 💥 BREAKING CHANGE - by default, now all __contains__ and __getitem__ accesses to in-sandbox sys.modules for modules that are not there, but they are in outside-sandbox sys.modules and are configured pass through, are lazily added to in-sandbox sys.modules and returned
    • This fixes a longstanding issue where transitive passed through imports were not in sys.modules inside of sandbox
    • This was affecting Pydantic because they use module namespace contents in sys.modules to affect how they evaluate type hints without importing
    • This is technically a backwards incompatible change because it affects sys.module behavior inside of sandbox, so we have provided a disable_lazy_sys_module_passthrough option in sandbox restriction config to opt-out if it breaks user workflows
  • Update openai-agents to >0.1
  • Set the OpenAI data converter as the Pydantic converter
    • The sys.modules issue being solved alongside an upstream resolution in OpenAI agents means that native Pydantic data converter can be used
    • Use of the OpenAI data converter is deprecated (and will be removed when we move to plugins)
  • Default all agents and openai modules (and their children) as passthrough for the entire SDK
    • We can consider instead making this part of the plugin when that comes around instead of global
    • Updated code to remove the manual passthroughs

Checklist

  1. Closes Validate OpenAI data converter necessity #912

@cretz cretz requested a review from a team as a code owner July 2, 2025 14:31
…ic-converter

# Conflicts:
#	tests/contrib/openai_agents/test_openai.py
@tconley1428
Copy link
Contributor

I'm trying to see what would cause these CI failures, it seems like what happens if the API key is set to an empty string.

@cretz
Copy link
Member Author

cretz commented Jul 2, 2025

I'm trying to see what would cause these CI failures, it seems like what happens if the API key is set to an empty string.

Correct. Forks don't have access to secrets. I have updated the code to skip when empty too.

@cretz cretz merged commit 9d40e86 into temporalio:main Jul 3, 2025
33 of 39 checks passed
@cretz cretz deleted the openai-pydantic-converter branch July 3, 2025 20:06
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.

Validate OpenAI data converter necessity
2 participants