From 4da5689b80a0ddfe3ccf447e91b5279fa7c4140a Mon Sep 17 00:00:00 2001 From: briandevans <252620095+briandevans@users.noreply.github.com> Date: Wed, 12 Aug 2026 00:30:18 -0700 Subject: [PATCH] fix(cli): run auto-describe LLM round-trip off the dashboard event loop POST /api/profiles/{name}/describe-auto called profile_describer.describe_profile() inline. That function is a plain def; it reaches agent.auxiliary_client.call_llm(), also a plain def, which makes a synchronous provider request with a 60-second ceiling. Held on the ASGI event loop that is six times the 10-second WebSocket ready-probe threshold web_server.py records as the point where the desktop app gives up (GH-73083). A single describe-auto on a slow or unreachable auxiliary provider therefore takes the whole dashboard offline for up to a minute, including the /api/ws and /api/pty sockets the desktop app and the Chat tab run on. Move the import and call into the default executor. _resolve_profile_dir() deliberately stays on the loop ahead of the hop: it is a name validation plus a single stat, and it owns the 400/404 responses that the handler's `except Exception` would otherwise turn into a 500. --- hermes_cli/web_routers/profiles.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hermes_cli/web_routers/profiles.py b/hermes_cli/web_routers/profiles.py index b5a88f696e..467f3af7fc 100644 --- a/hermes_cli/web_routers/profiles.py +++ b/hermes_cli/web_routers/profiles.py @@ -1157,10 +1157,21 @@ async def describe_profile_auto_endpoint(name: str, body: ProfileDescribeAuto): ``ok: false`` with a reason rather than an HTTP error so the UI can surface it inline and let the operator fix config and retry. """ + # Resolution stays on the loop: it is a name check plus one stat, and it + # owns the 400/404 mapping that the ``except Exception`` below would + # otherwise flatten into a 500. _resolve_profile_dir(name) - try: + + def _run(): from hermes_cli import profile_describer - outcome = profile_describer.describe_profile(name, overwrite=bool(body.overwrite)) + return profile_describer.describe_profile(name, overwrite=bool(body.overwrite)) + + try: + # describe_profile() is a plain def that reaches auxiliary_client's + # call_llm() — a synchronous provider round-trip with a 60 s ceiling, + # six times the desktop's WebSocket disconnect threshold. Held on the + # loop it stalls every other dashboard request for that whole window. + outcome = await asyncio.get_running_loop().run_in_executor(None, _run) except Exception as e: _log.exception("POST /api/profiles/%s/describe-auto failed", name) raise HTTPException(status_code=500, detail=str(e))