From f46f60353c6c170ef12c6f0b3ee7b4c294b116e3 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Tue, 15 Sep 2026 08:13:06 +0900 Subject: [PATCH] Python: stabilize Hyperlight output cleanup test --- .../tests/hyperlight/test_hyperlight_codeact.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py b/python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py index 897d69d94d4..c9abad2af7b 100644 --- a/python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py +++ b/python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py @@ -1293,14 +1293,17 @@ async def test_execute_code_tool_clears_output_after_rejection( max_output_file_bytes=3, ) config = execute_code._build_run_config() - output_root = Path(cast(Any, execute_code._registry)._get_or_create_entry(config).output_dir.name) + registry = cast(Any, execute_code._registry) + output_root = Path(registry._get_or_create_entry(config).output_dir.name) try: contents = await execute_code.invoke(arguments={"code": "create-memory-output"}) _assert_bounded_output_error(contents, "per-file output limit") - remaining_outputs = await asyncio.to_thread(lambda: list(output_root.iterdir())) - assert remaining_outputs == [] + # Rejection retires the entry and removes its directory on the single cleanup worker. + # Wait behind that cleanup before checking the directory, which may already be gone. + await asyncio.wrap_future(registry._cleanup_executor.submit(lambda: None)) + assert not await asyncio.to_thread(output_root.exists) finally: _close_execute_code_registry(execute_code)