From 95f766cb7418af3871dbda522d84166817150280 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Thu, 23 Jul 2026 18:35:57 -0400 Subject: [PATCH] Normalize asyncio.TimeoutError to builtin in task input timeout (py3.10) asyncio.wait_for raises asyncio.TimeoutError, a distinct type from the builtin before Python 3.11, so an elicitation-callback timeout leaked an uncaught type on 3.10. Convert it to the builtin TimeoutError the rest of the drive raises. --- fastmcp_tasks/fastmcp_tasks/client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fastmcp_tasks/fastmcp_tasks/client.py b/fastmcp_tasks/fastmcp_tasks/client.py index 19def1a46..78744acb1 100644 --- a/fastmcp_tasks/fastmcp_tasks/client.py +++ b/fastmcp_tasks/fastmcp_tasks/client.py @@ -199,7 +199,15 @@ async def _answer_input_requests( ) budget = _remaining() call = elicitation_callback(context, request.params) - answer = await (asyncio.wait_for(call, budget) if budget is not None else call) + try: + answer = await ( + asyncio.wait_for(call, budget) if budget is not None else call + ) + except asyncio.TimeoutError as exc: + # Normalize to the builtin: on Python 3.10 `asyncio.wait_for` raises + # `asyncio.TimeoutError`, a distinct type from the builtin the rest of + # the drive raises (they were unified in 3.11). + raise TimeoutError(f"Task {task_id} timed out awaiting input") from exc if isinstance(answer, mcp_types.ErrorData): raise ToolError(f"Elicitation for task {task_id} failed: {answer.message}") responses[surfaced_key] = answer.model_dump(