Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@vcfgv
Copy link
Collaborator

@vcfgv vcfgv commented Dec 5, 2025

📝 Pull Request Template

1. Related Issue

Closes # (issue number)

2. Type of Change (select one)

Bug Fix

3. Description

Problem

Using asyncio.to_thread(_resolve_local_agent_class, spec) occasionally hangs on Windows during request handling.

Root cause (short)

  • CPython serializes imports with a global import lock.
  • asyncio.to_thread runs import_module in a worker thread; if the main thread (or another thread) is also importing or holding resources, the worker can block waiting for the import lock while the main thread waits for the worker — producing a deadlock-like hang.
  • Windows scheduling, platform-specific init in some libraries, and antivirus/file-scanner delays make this race more likely there.

Why it shows up in this codepath

  • The threaded import is performed during request handling (_build_local_agent), so any blocking stalls the request pipeline between “Resolved prompt” and “Launching in-process agent”.

Short mitigations

  • Add timeout + synchronous fallback (applied): try asyncio.to_thread with asyncio.wait_for(..., timeout=5s) and fall back to sync _resolve_local_agent_class on timeout.

4. Testing

  • I have tested this locally.
  • I have updated or added relevant tests.

5. Checklist

@su8su su8su merged commit 8ec10f3 into main Dec 5, 2025
3 checks passed
@su8su su8su deleted the bugfix/resolve-local-agent-class-with-timeout-backoff branch December 5, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.