From 485fe9d1b2db437255176a790a3bd6d96da4b860 Mon Sep 17 00:00:00 2001 From: cthomas Date: Tue, 6 Jan 2026 11:00:20 -0800 Subject: [PATCH] fix: set task name earlier for logging (#8333) --- letta/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/letta/utils.py b/letta/utils.py index 6b77b5fc..f360d8f3 100644 --- a/letta/utils.py +++ b/letta/utils.py @@ -1445,11 +1445,12 @@ async def bounded_gather(coros: list[Coroutine], max_concurrency: int = 10) -> l semaphore = asyncio.Semaphore(max_concurrency) async def bounded_coro(index: int, coro: Coroutine, coro_name: str): + # Set task name for diagnostics before acquiring semaphore + task = asyncio.current_task() + if task: + task.set_name(f"bounded[{coro_name}]") + async with semaphore: - # Set task name for diagnostics - task = asyncio.current_task() - if task: - task.set_name(f"bounded[{coro_name}]") result = await coro return (index, result)