Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix(core): unwrap ExceptionGroup in OAuth stream generator (#9346)

Kian Jonescbbb6d776d02
diff --git a/letta/server/rest_api/routers/v1/tools.py b/letta/server/rest_api/routers/v1/tools.py
index a17590c1a..1884b4253 100644
--- a/letta/server/rest_api/routers/v1/tools.py
+++ b/letta/server/rest_api/routers/v1/tools.py
@@ -742,6 +742,13 @@ async def connect_mcp_server(
async for event in server.mcp_manager.handle_oauth_flow(request=request, actor=actor, http_request=http_request):
yield event
return
+ except ExceptionGroup as eg:
+ # Handle ExceptionGroup wrapping (Python 3.11+ async TaskGroup can wrap exceptions)
+ # Unwrap and handle the first exception in the group
+ exception_to_handle = eg.exceptions[0] if eg.exceptions else eg
+ detailed_error = drill_down_exception(exception_to_handle)
+ logger.error(f"Error in OAuth stream (ExceptionGroup):\n{detailed_error}")
+ yield oauth_stream_event(OauthStreamEvent.ERROR, message=f"Internal error: {detailed_error}")
except Exception as e:
detailed_error = drill_down_exception(e)
logger.error(f"Error in OAuth stream:\n{detailed_error}")