fix: global interrupt Event contaminates all concurrent tool invocations - #22156
fix: global interrupt Event contaminates all concurrent tool invocations#22156amathxbt wants to merge 1 commit into
Conversation
|
Reproduction import threading
from tools.interrupt import request_interrupt, is_interrupted, clear_interrupt
results = []
def worker():
import time; time.sleep(0.1)
results.append(is_interrupted()) # Should be False for this thread
t = threading.Thread(target=worker)
t.start()
request_interrupt() # Interrupt the main thread
t.join()
assert results == [False], f'Got {results}' # FAILS: worker sees the interruptRoot cause: Fix: Uses |
|
Duplicate of #7930 (merged 2026-04-11), which already implemented per-thread interrupt scoping using |
|
Thanks for the clear bug report and reproduction. This is an automated hermes-sweeper review, and current Evidence:
Closing this PR as already implemented on main. |
Bug
tools/interrupt.pyuses a single module-levelthreading.Event(_interrupt_event). When one tool invocation callsrequest_interrupt(), every other concurrently running tool also sees the event as set and terminates early.Impact
In multi-threaded execution environments (ACP gateway, test parallelism) a single user-requested interrupt kills all in-flight tool calls, not just the intended one. Unrelated background tasks are silently cancelled.
Fix
Make
_interrupt_eventathreading.local()instance so each thread carries its own event. Addsget_interrupt_event()to retrieve the per-thread event and keeps the module-level helpers working transparently.