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.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user