Repository navigation
Conversation
u7-u7
marked this pull request as ready for review
October 28, 2026 03:12
This branch has not been deployed
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.
Change Summary
Prevent
DaemonThreadPoolExecutorworkers from blocking interpreter exit after a tool call times out and cleanup callsshutdown(wait=False, cancel_futures=True).The executor already marks its threads as daemons, but also registers them in CPython's
concurrent.futures.thread._threads_queues. CPython's interpreter-exit hook joins every thread in that registry, including daemon threads. A stuck synchronous network call can therefore keep the CLI alive indefinitely despite non-waiting shutdown. The web-search and content-optimizer paths use this executor specifically to avoid that behavior.Do not register these daemon workers in the interpreter-exit join registry. Explicit
shutdown(wait=True)continues to joinself._threads, and ordinary future results, exceptions and queued-work cancellation remain unchanged. Pending work may be abandoned on interpreter exit, as required by this executor's existing documented daemon contract.Adds four regression tests, including an actual child interpreter with a blocked worker. On the base revision, it prints
shutdown returnedbut exceeds the 15-second process-exit timeout. With the fix, it exits normally. No executor or threading mocks are used.Related issue number
No existing matching issue or PR found in the duplicate search.
Validation
Tested on CPython 3.12.14 with the SDK installed from source:
python -m pytest tests/utils/test_thread_util.py -q: 4 passed (before fix: 1 failed, 3 passed).python -m pytest tests/utils -q: 151 passed, 30 subtests passed, 1 unrelated baseline failure.TestAgentToolTranscript.test_save_transcript_writes_message_objects_and_dictsexpectssubagents/worker-1.jsonl, while current code writes.ms_agent/subagents/worker-1.jsonl. Reproduced with the original unmodified executor as well.pre-commit installcompleted.pre-commit run --files ms_agent/utils/thread_util.py tests/utils/test_thread_util.py: all applicable hooks passed.pre-commit run --all-files: run, but not passing on the base tree's existing lint/formatting problems. Unrelated autoformat changes were discarded; only the executor and regression test are included.git diff --check: passed.Not tested: full repository suite, real external search/LLM calls, Windows, or other Python versions. This class already depends on CPython's private
_workerimplementation; this change does not add a new private dependency.AI-generated change and tests, independently reviewed by another automated reviewer. No human-review attestation is claimed.
Checklist
pre-commit installandpre-commit run --all-filesbefore git commit, and passed lint check. (Run; full-repo baseline failures disclosed above. Changed-file checks pass.)