diff --git a/CHANGELOG.md b/CHANGELOG.md index 40e806916..7769f776d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ to include examples, links to docs, or any other relevant information. retried on its configured interval instead. - Nexus-context workflow/activity starts no longer set `on_conflict_options` when there are no links or callbacks to attach. +- The workflow sandbox now passes `pydantic_core` through by default, alongside `pydantic`. ### Security diff --git a/temporalio/worker/workflow_sandbox/_restrictions.py b/temporalio/worker/workflow_sandbox/_restrictions.py index 23774fcd2..3e6e0d6ba 100644 --- a/temporalio/worker/workflow_sandbox/_restrictions.py +++ b/temporalio/worker/workflow_sandbox/_restrictions.py @@ -513,6 +513,8 @@ def with_child_unrestricted(self, *child_path: str) -> SandboxMatcher: # Due to how Pydantic is importing lazily inside of some classes, we choose # to always pass it through "pydantic", + # Same for its compiled core, which Pydantic-based libraries import lazily + "pydantic_core", } ) diff --git a/tests/contrib/openai_agents/test_openai_replay.py b/tests/contrib/openai_agents/test_openai_replay.py index 6db463392..7c9a586b2 100644 --- a/tests/contrib/openai_agents/test_openai_replay.py +++ b/tests/contrib/openai_agents/test_openai_replay.py @@ -1,3 +1,4 @@ +import warnings from pathlib import Path import pytest @@ -32,6 +33,10 @@ async def test_replay(file_name: str) -> None: with (Path(__file__).with_name("histories") / file_name).open("r") as f: history_json = f.read() + with warnings.catch_warnings(record=True) as recorder: + warnings.filterwarnings( + "always", message=r"Module .* was imported after initial workflow load" + ) await Replayer( workflows=[ ResearchWorkflow, @@ -44,3 +49,10 @@ async def test_replay(file_name: str) -> None: ], plugins=[OpenAIAgentsPlugin()], ).replay_workflow(WorkflowHistory.from_json("fake", history_json)) + + # Sandbox imports during an activation count toward the deadlock timeout + assert not [ + str(w.message) + for w in recorder + if "was imported after initial workflow load" in str(w.message) + ]