Skip to content

fix(daemon_pool): support both Python 3.11 and 3.14 worker signatures - #85961

Open
ypQQ1984 wants to merge 1 commit into
NousResearch:mainfrom
ypQQ1984:fix/daemon-pool-dual-env
Open

fix(daemon_pool): support both Python 3.11 and 3.14 worker signatures#85961
ypQQ1984 wants to merge 1 commit into
NousResearch:mainfrom
ypQQ1984:fix/daemon-pool-dual-env

Conversation

@ypQQ1984

Copy link
Copy Markdown
Contributor

Problem

Hermes ships two runtimes sharing the same tools/daemon_pool.py: the gateway service runs on .venv Python 3.11 while the desktop runtime runs system Python 3.14. The upstream implementation only supports a single Python version:

  • 3.8-3.13: _worker(ref, work_queue, initializer, initargs)
  • 3.14: _worker(ref, ctx, work_queue) with _create_worker_context()

A single-version implementation crashes the other runtime with AttributeError: DaemonThreadPoolExecutor has no attribute ..., which cascades into _compress_context / relay conversation initialization failures — surfacing as agent errors on messaging platforms (Feishu).

Fix

Detect at runtime with hasattr(self, "_create_worker_context") and build worker args for the matching signature, so both 3.11 and 3.14 runtimes work from the same file.

Verification

Tested on both interpreters: submit() succeeds on Python 3.11 (uses _initializer/_initargs path) and Python 3.14 (uses _create_worker_context path).

Hermes ships two runtimes sharing the same daemon_pool.py: the gateway
service runs on .venv Python 3.11 while the desktop runtime runs system
Python 3.14. The upstream implementation only supports one signature:

- 3.8-3.13: _worker(ref, work_queue, initializer, initargs)
- 3.14: _worker(ref, ctx, work_queue) with _create_worker_context()

A single-version implementation breaks the other runtime with
AttributeError, which cascades into conversation compression and relay
initialization failures (agent errors on messaging platforms).

Detect at runtime with hasattr(self, "_create_worker_context") and
build the worker args accordingly, so both runtimes work from the same
file.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades duplicate This issue or pull request already exists labels Aug 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #57459: both repair the same tools/daemon_pool.py CPython 3.14 WorkerContext/_worker signature transition. #57459 is the earlier open implementation.

@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

fix(daemon_pool): support both Python 3.11 and 3.14 worker signatures

  1. Version detection via hasattr(self, "_create_worker_context") is fragile: a subclass could define that name, and the attribute could disappear in a future 3.x. sys.version_info >= (3, 14) (or an import guard) is explicit and self-documenting.
  2. The new 3.14 branch has zero test coverage. A unit test that fakes both signatures (a stub _create_worker_context/context object and captured threading.Thread target/args) would catch signature drift — e.g. if 3.14's _worker argument order or the context object shape changes in a patch release.
  3. Minor style: the inline comment is in Chinese and references a "本地 patch (local patch)" — upstream repo convention is English comments; rephrase for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants