fix(cli): keep /reload-mcp off the input thread - #39446
Open
LeonSGP43 wants to merge 1 commit into
Open
Conversation
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for tracing the manual reload path; the underlying issue remains present on current main (cli.py:10698 and cli.py:10738 still call _reload_mcp() synchronously).
Problems
- PR
cli.py:10923starts a worker but then callsjoin(timeout=timeout_seconds). With the default 30 seconds, the command processor can still be blocked for 30 seconds. Current main deliberately removed the equivalent watcher join in972aa33d376e8cb308466192ee545c879459fd0dbecause it frozeprocess_loop. - The new timeout test uses a 0.01-second join (
tests/cli/test_cli_loading_indicator.py:89-96), so it verifies timeout formatting but not that/reload-mcpreturns while reload work remains blocked. It also exercises only the pre-approved route.
Suggested changes
- Start the daemon worker and return immediately, following current
cli.py:10538-10546; report completion from the worker rather than joining it. - Add an event-blocked reload test proving both approved paths return before reload completion.
Automated hermes-sweeper review.
| """Run MCP reload on a worker thread so slash-command input stays recoverable.""" | ||
| reload_thread = threading.Thread(target=self._reload_mcp, daemon=True) | ||
| reload_thread.start() | ||
| reload_thread.join(timeout=timeout_seconds) |
Contributor
There was a problem hiding this comment.
This join() still blocks the command-processing thread for the default 30 seconds. Current main removed the equivalent config-watcher join in 972aa33d3 because it froze process_loop; please return immediately after starting the daemon worker instead.
13 tasks
This was referenced Aug 5, 2026
Open
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.
Summary
Fixes the interactive CLI
/reload-mcpfreeze by moving the user-triggered reload path onto a worker thread with the same 30s timeout behavior the config-watcher reload path already uses. This keeps the prompt/input thread recoverable even if an MCP server hangs during shutdown or reconnect.Closes #39418.
What changed
/reload-mcpexecutions through_run_reload_mcp_with_timeout()instead of calling_reload_mcp()inline on the CLI thread/reload-mcpnow executes off the main thread and surfaces the timeout warning without blocking foreverVerification
../.base/.venv/bin/python -m pytest -o addopts='' tests/cli/test_cli_loading_indicator.py../.base/.venv/bin/python -m ruff check cli.py tests/cli/test_cli_loading_indicator.pygit diff --check