Skip to content

fix(daemon_pool): support Python 3.14 WorkerContext API - #81118

Open
jcrabapple wants to merge 1 commit into
NousResearch:mainfrom
jcrabapple:fix/daemon-pool-py314-compat
Open

fix(daemon_pool): support Python 3.14 WorkerContext API#81118
jcrabapple wants to merge 1 commit into
NousResearch:mainfrom
jcrabapple:fix/daemon-pool-py314-compat

Conversation

@jcrabapple

Copy link
Copy Markdown

CPython 3.14 removed ThreadPoolExecutor._initializer / _initargs and replaced them with a WorkerContext pattern, and _worker() changed from 5 args to 3. This breaks DaemonThreadPoolExecutor on any system running Python 3.14 (Fedora 44, etc.) with:

AttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer'

This manifests in the CLI as intermittent tool-call failures during parallel operations (skill_view, web_search, search_files, and any other concurrent tool dispatch).

The fix detects the available API at runtime via hasattr(self, '_initializer') and branches accordingly — old path for 3.8–3.13, new WorkerContext path for 3.14+. Verified on both Python 3.11 and 3.14.

The daemon pool never passes a custom initializer, so None/() is the correct equivalent in the 3.14 path.

CPython 3.14 removed ThreadPoolExecutor._initializer / _initargs and
replaced them with a WorkerContext pattern, and _worker() changed from
5 args to 3.  Detect the available API at runtime and branch accordingly
so DaemonThreadPoolExecutor works on both 3.8-3.13 and 3.14+.

Fixes 'DaemonThreadPoolExecutor' object has no attribute '_initializer'
on Python 3.14 (Fedora 44, etc.).
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades duplicate This issue or pull request already exists labels Aug 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #65182. Both patch tools/daemon_pool.py for the same CPython 3.14 WorkerContext/_worker compatibility change; #65182 is the earlier open implementation.

@spfcraze

Copy link
Copy Markdown
Contributor

Independent verification of this fix (Python 3.14.4, Linux x86-64, 2026-08-10).

I independently hit the same crash — AttributeError: 'DaemonThreadPoolExecutor' object has no attribute '_initializer' on 3.14 — and implemented a near-identical WorkerContext fix (hasattr-guarded branch). Since our approaches converge on the same mechanism, here's the sabotage-verified evidence I generated while validating:

Scenario Result
test_daemon_pool.py on 3.14, unfixed tree 5/5 FAILAttributeError: _initializer
Same tests on 3.14 with the WorkerContext fix 5/5 PASS
Same tests on 3.12 with the fix 5/5 PASS (backward compatible)
test_delegate.py on 3.14, unfixed 41 failed / 64 passed
test_delegate.py on 3.14, fixed 63/63 PASS
test_compression_concurrent_fork.py + test_async_delegation.py, fixed 62/62 PASS

Key detail worth noting in the fix: the crash is NOT only in daemon_pool.py's own tests — delegate_tool.py:2802 uses this pool for its subagent timeout executor, so the fix unblocks delegation/orchestration on 3.14, not just the pool itself. My regression tests run the pool with an initializer/initargs in a subprocess (the exact 3.14 WorkerContext path) and verify workers receive the initialized thread-local.

No changes requested to this PR — just confirming the fix is correct and load-bearing from an independent run. Happy to add the regression tests here if useful.

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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants