From 182739fcda011a33065db01e31d0d6d2d70cd4c8 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 30 May 2026 07:14:39 -0700 Subject: [PATCH] test(interrupt): assert no leaked tid instead of no-op block Follow-up on the #35309 regression test: the trailing `with _lock: pass` asserted nothing. Replace it with a concrete assertion that _interrupted_threads is empty after the worker exits, directly verifying the leak the fix prevents. --- tests/tools/test_interrupt.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/tools/test_interrupt.py b/tests/tools/test_interrupt.py index 02d8cbdff03..5d614f62bc5 100644 --- a/tests/tools/test_interrupt.py +++ b/tests/tools/test_interrupt.py @@ -270,18 +270,14 @@ class TestRunToolCleanupOnBaseException: f"_tool_worker_threads not cleaned up: {agent._tool_worker_threads}" ) - # Verify no stale tid is left in the global interrupt set - # (the worker thread is recycled by ThreadPoolExecutor, so any - # leftover tid would poison the next task on that thread). - # We can't predict the tid, but we know the worker thread is done - # (the call returned), so the set should be empty for this test's - # tid range. Check that no tid from our agent's tracking leaked. + # Verify no stale tid is left in the global interrupt set. The + # worker thread is recycled by ThreadPoolExecutor, so a leaked tid + # would poison the next task on that thread. We cleared the set at + # the start and never set any interrupt ourselves, so a leak from + # _run_tool is the only way an entry could land here. with _lock: - # The only tids that should be in _interrupted_threads are - # ones we explicitly set — we didn't set any, so it should - # be empty (modulo other test interference, hence the - # per-agent tracking assertion above). - pass + leaked = set(_interrupted_threads) + assert leaked == set(), f"leaked tids in _interrupted_threads: {leaked}" # ---------------------------------------------------------------------------