From 1ffffc1cf1b6c2bbeeb543669673b6fcd10f4d23 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 23 Jun 2026 05:50:53 -0700 Subject: [PATCH] Studio: correct anyio<4.14 comments to the real #6483 cause (#6581) #6579 reworded these comments to attribute the failure to a half-resolved install and claimed a clean 4.14 is fine on 3.13. That is wrong: #6483 is a genuine anyio 4.14 + Python 3.13 regression. 4.14 added a per-task cancel scope in its asyncio backend (TaskHandle/_run_coro) that gets exited in the wrong task under starlette's collapsing task group, raising the cancel-scope RuntimeError on streaming; 4.13 has no such code and is unaffected (the reporter confirmed 4.13.0 fixes it). The TaskHandle ImportError is only the secondary macOS-arm symptom from the mlx-vs-cap version fight. Comments only. --- studio/backend/requirements/no-torch-runtime.txt | 2 +- .../backend/requirements/single-env/constraints.txt | 10 +++++----- .../single-env/overrides-darwin-arm64.txt | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txt index a611c009fb..9796fc3a50 100644 --- a/studio/backend/requirements/no-torch-runtime.txt +++ b/studio/backend/requirements/no-torch-runtime.txt @@ -56,7 +56,7 @@ httpx httpcore certifi idna -anyio>=3.0,<4.14.0 # one consistent <4.14: 4.14's TaskHandle importers over a stale 4.13 _core/_tasks -> ImportError (#6483) +anyio>=3.0,<4.14.0 # 4.14 asyncio cancel-scope RuntimeError on Py3.13 streaming (#6483); 4.13 unaffected sniffio h11 diff --git a/studio/backend/requirements/single-env/constraints.txt b/studio/backend/requirements/single-env/constraints.txt index a916c6fc75..9e81880016 100644 --- a/studio/backend/requirements/single-env/constraints.txt +++ b/studio/backend/requirements/single-env/constraints.txt @@ -13,11 +13,11 @@ fastmcp>=3.0.2 mcp>=1.24,<2 websockets>=15.0.1 -# Keep anyio on one consistent <4.14 line. anyio 4.14 added TaskHandle (imported -# by __init__.py and the asyncio backend from _core/_tasks); a clean 4.14 is fine -# on 3.13. The real failure (#6483) is a half-resolved install: a stale 4.13 -# _core/_tasks (no TaskHandle) under 4.14's importers raises ImportError and 500s -# the server. Global cap so later with-deps steps can't re-resolve it up. +# Cap anyio <4.14: 4.14's new asyncio per-task cancel scope (TaskHandle/_run_coro) +# gets exited in the wrong task on Python 3.13 under starlette's collapsing task +# group, raising "RuntimeError: ... exit a cancel scope that isn't the current +# task's" on streaming responses (#6483); 4.13 has no such code. Global cap so +# later with-deps steps can't re-resolve it up. anyio<4.14.0 pandas==2.3.3 diff --git a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt b/studio/backend/requirements/single-env/overrides-darwin-arm64.txt index a0e73c7efc..56b948644f 100644 --- a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt +++ b/studio/backend/requirements/single-env/overrides-darwin-arm64.txt @@ -4,10 +4,9 @@ # happens at runtime via the side-car venvs. transformers>=4.57.6 -# mlx-vlm / mlx-lm pull anyio>=4.14, which fights the constraints.txt cap -# (anyio<4.14.0). The -c constraint loses that fight on macOS-arm, leaving a -# half-resolved anyio (4.14 importers over a stale 4.13 _core/_tasks with no -# TaskHandle) that ImportErrors and 500s the server (#6483; clean 4.14 is fine, -# it is the mix that breaks). An override wins the fight, so force one -# consistent <4.14 here too. +# mlx-vlm / mlx-lm pull anyio>=4.14, which fights the constraints.txt cap (needed +# for the 4.14 Python-3.13 streaming cancel-scope RuntimeError, #6483). The -c +# constraint loses that fight on macOS-arm, leaving a half-resolved 4.14/4.13 +# anyio that also ImportErrors on TaskHandle and 500s the server. An override +# wins the fight, so force one consistent <4.14 here too. anyio<4.14.0