From 066ed87e73b8fc3f398d64dffc7157b16ae506b6 Mon Sep 17 00:00:00 2001 From: Jinglong Wang Date: Wed, 24 Jun 2026 10:23:09 +0800 Subject: [PATCH] Fix OpenAI LLM test memory exhaustion --- test/sdk/core/models/test_openai_llm.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test/sdk/core/models/test_openai_llm.py b/test/sdk/core/models/test_openai_llm.py index af33cc82a..5e9251518 100644 --- a/test/sdk/core/models/test_openai_llm.py +++ b/test/sdk/core/models/test_openai_llm.py @@ -103,16 +103,10 @@ def __init__(self, *a, **k): sys.modules["smolagents.models"] = sa_mod _setup_stubs() -# Now that stubs are in place, attempt to execute the module so imports resolve to our stubs. -# If this early import fails, clean up the partial module so the later, properly-patched import can run. -try: - spec.loader.exec_module(openai_llm_module) - OpenAIModel = getattr(openai_llm_module, "OpenAIModel", None) -except Exception: - # Remove any partially-imported module to avoid interfering with later imports - if MODULE_NAME in sys.modules: - del sys.modules[MODULE_NAME] - OpenAIModel = None +# Do not execute the module here. The import below runs after the full mock +# graph is installed; importing it twice can initialise the real monitoring +# stack during collection and exhaust local resources. +OpenAIModel = None def make_chunk(content, reasoning=None, role=None):