fix(runtime): detach concurrent tool batches on interrupt - #24201
Open
qWaitCrypto wants to merge 2 commits into
Open
qWaitCrypto wants to merge 2 commits into
qWaitCrypto wants to merge 2 commits into
Conversation
Collaborator
|
Thanks for isolating a real concurrent-interrupt responsiveness issue. Current Problems
Suggested changes
Automated hermes-sweeper review. |
qWaitCrypto
force-pushed
the
fix/concurrent-tool-interrupt
branch
from
August 25, 2026 04:07
45a790e to
57d3892
Compare
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a runtime bug where interrupting a concurrent tool batch did not actually release the current turn promptly.
Before this change,
_execute_tool_calls_concurrent()usedwith ThreadPoolExecutor(...). On interrupt, Hermes cancelled futures that had not started yet, butThreadPoolExecutor.__exit__()still calledshutdown(wait=True). In practice,/stopor a new user message could appear to succeed while the current turn was still blocked on already-running tools likeweb_search, file reads, or custom plugins that do not actively poll for interrupts.This approach keeps the normal concurrent path intact, but makes interrupted concurrent batches detachable so the current turn can return promptly.
Related Issue
NA
Type of Change
Changes Made
run_agent.pyto track the active concurrent tool batch on the agentThreadPoolExecutorlifetime with explicit attach/detach/shutdown handlinginterrupt()so the current turn does not wait for long-running workers to draintests/run_agent/test_concurrent_interrupt.pycovering prompt interrupt return and late-result suppressionHow to Test
tests/run_agent/test_concurrent_interrupt.py:3 passedtests/run_agent/test_run_agent.py -k concurrent:22 passed, 303 deselectedtests/run_agent/test_tool_executor_contextvar_propagation.py tests/run_agent/test_interrupt_propagation.py tests/run_agent/test_tool_call_guardrail_runtime.py:19 passedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passpytestvia/home/cyt/miniconda3/envs/meta_workflow_py312/bin/pythonDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Manual reproduction harness against
upstream/mainand this branch, forcing_MAX_TOOL_WORKERS = 1so one tool is running while the batch is interrupted:The baseline reproduces the bug: one second after interrupt, the concurrent batch is still alive and the late tool result eventually lands. The fixed branch returns promptly and preserves interrupt placeholders instead of accepting late completions.