Skip to content

fix(gateway): staged inactivity warning before timeout escalation#6387

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-b0a4b31e
Apr 9, 2026
Merged

fix(gateway): staged inactivity warning before timeout escalation#6387
teknium1 merged 2 commits into
mainfrom
hermes/hermes-b0a4b31e

Conversation

@teknium1

@teknium1 teknium1 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #6263 by @Helmi (cherry-picked onto current main) with two bug fixes.

Adds a pre-timeout warning notification to the gateway inactivity timeout. When the agent has been idle for gateway_timeout_warning seconds (default 900s / 15 min), a single notification is sent. If inactivity continues to gateway_timeout (default 1800s / 30 min), the full timeout fires as before.

This gives users on slow API providers a heads-up instead of a surprise timeout.

Bug fixes on top of the original PR

① Unbound exception variable — the original had except Exception: followed by logger.debug('...%s', _ne). The _ne variable wasn't bound to this exception (it existed in an outer scope from a different try/except). Fixed: except Exception as _warn_err:

② Warning message remaining-time math — the original said "timed out in {_warn_mins} min" where _warn_mins = _agent_warning // 60. That's the elapsed time, not the remaining time. With defaults (warning=15min, timeout=30min) it happened to be correct, but with warning=10min / timeout=30min it would say "timed out in 10 min" when 20 minutes remain. Fixed: _remaining_mins = (_agent_timeout - _agent_warning) // 60

Changes

  • gateway/run.py — Warning check in poll loop, config bridge for env var
  • hermes_cli/config.pygateway_timeout_warning: 900 in DEFAULT_CONFIG
  • cli-config.yaml.example — Documented both timeout keys
  • tests/gateway/test_gateway_inactivity_timeout.py — 8 tests, all pass

Config

agent:
  gateway_timeout: 1800          # full timeout (seconds, 0 = unlimited)
  gateway_timeout_warning: 900   # warning before timeout (seconds, 0 = disable)

Example message at 15 min idle:

⚠️ No activity for 15 min. If the agent does not respond soon, it will be timed out in 15 min. You can continue waiting or /reset.

Fixes #6260

Helmi and others added 2 commits April 8, 2026 19:58
Introduce gateway_timeout_warning (default 900s) as a pre-timeout alert
layer.  When inactivity reaches the warning threshold, a single
notification is sent to the user offering to wait or reset.  If
inactivity continues to the gateway_timeout (default 1800s), the full
timeout fires as before.

This gives users a chance to intervene before work is lost on slow
API providers without disabling the safety timeout entirely.

Config: agent.gateway_timeout_warning in config.yaml, or
HERMES_AGENT_TIMEOUT_WARNING env var (0 = disable warning).
…rning

- 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)
@teknium1 teknium1 merged commit af4abd2 into main Apr 9, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inactivity timeout fires repeatedly with MiniMax 2.7 highspeed

2 participants