From af4abd2f2253bee78905493f565f4a3f99e1aec0 Mon Sep 17 00:00:00 2001 From: Teknium Date: Wed, 8 Apr 2026 19:59:44 -0700 Subject: [PATCH] fix: correct unbound exception variable and remaining-time math in warning - Bind exception in warning send handler (was using stale _ne from outer scope) - Calculate remaining time until timeout correctly: (timeout - warning) // 60 instead of warning // 60 (which equals elapsed time, not remaining) --- gateway/run.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gateway/run.py b/gateway/run.py index ddb57bd7..33336081 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -7157,18 +7157,19 @@ class GatewayRunner: _warning_fired = True _warn_adapter = self.adapters.get(source.platform) if _warn_adapter: - _warn_mins = int(_agent_warning // 60) or 1 + _elapsed_warn = int(_agent_warning // 60) or 1 + _remaining_mins = int((_agent_timeout - _agent_warning) // 60) or 1 try: await _warn_adapter.send( source.chat_id, - f"⚠️ No activity for {_warn_mins} min. " + f"⚠️ No activity for {_elapsed_warn} min. " f"If the agent does not respond soon, it will " - f"be timed out in {_warn_mins} min. " + f"be timed out in {_remaining_mins} min. " f"You can continue waiting or use /reset.", metadata=_status_thread_metadata, ) - except Exception: - logger.debug("Inactivity warning send error: %s", _ne) + except Exception as _warn_err: + logger.debug("Inactivity warning send error: %s", _warn_err) if _idle_secs >= _agent_timeout: _inactivity_timeout = True break