-
Notifications
You must be signed in to change notification settings - Fork 3.2k
HITL sessions preserved forever → memory leak #5165
Description
Description
When a session expires with pending_tool_calls (user abandoned a HITL prompt), the cleanup loop skips deletion with no TTL. The session stays in [_session_keys] and [_user_sessions] forever. Every cleanup cycle (every 5 min) logs one line per accumulated session:
Package: [ag-ui-adk] v0.5.1
File: [ag_ui_adk/session_manager.py] → [_cleanup_expired_sessions()]
Root Cause (line ~755)
if has_pending:
logger.info(...) # ← no delete, no TTL, accumulates forever
else:
await self._delete_session(session)
No hitl_max_wait_seconds parameter exists. No _hitl_preserved_since timestamp tracking. Once a session enters this branch it never leaves unless the user responds.
Fix
Add hitl_max_wait_seconds: Optional[int] = 7200 to [SessionManager.init] track first-preserved time in [_hitl_preserved_since: Dict[str, float]], and force-delete after the limit is exceeded. Expose the same parameter through [ADKAgent.init].