From ffe4ec1c63f3d6d360950790715c48dad7aa220e Mon Sep 17 00:00:00 2001 From: chrischristiansen-glitch Date: Sat, 23 May 2026 21:09:59 +0200 Subject: [PATCH] fix: await get_session and create_session (async ADK 1.x API) --- agents/core-logic/app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agents/core-logic/app.py b/agents/core-logic/app.py index 9a7aa37..da81c41 100644 --- a/agents/core-logic/app.py +++ b/agents/core-logic/app.py @@ -52,10 +52,10 @@ class RunResponse(BaseModel): response: str -def _ensure_session(user_id: str, session_id: str): - """Get existing session or create a new one. Handles both ADK 1.x and 2.x.""" +async def _ensure_session(user_id: str, session_id: str): + """Await get_session; create if missing or raises.""" try: - session = session_service.get_session( + session = await session_service.get_session( app_name=APP_NAME, user_id=user_id, session_id=session_id, @@ -63,9 +63,9 @@ def _ensure_session(user_id: str, session_id: str): if session is not None: return session except Exception: - pass # session doesn't exist — fall through to create + pass - session = session_service.create_session( + session = await session_service.create_session( app_name=APP_NAME, user_id=user_id, session_id=session_id, @@ -82,7 +82,7 @@ async def health(): @app.post("/run", response_model=RunResponse) async def run(req: RunRequest): try: - _ensure_session(req.user_id, req.session_id) + await _ensure_session(req.user_id, req.session_id) runner = Runner( agent=root_agent,