Skip to content

gateway: debounce queued text follow-ups during active sessions (salvage of #31235)#31341

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f7e72d1a
May 24, 2026
Merged

gateway: debounce queued text follow-ups during active sessions (salvage of #31235)#31341
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f7e72d1a

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #31235 by @pnascimento9596 — focused B1.2-only follow-up to the closed #29943.

What this makes true

When a user sends rapid text follow-ups during an active turn, all of them survive as one merged next-turn message instead of being clobbered or fragmenting the turn.

Mechanism

  • New busy_text_mode=queue (default) on BasePlatformAdapter. Text follow-ups during an active session buffer into one TextDebounceState per session.
  • Bounded debounce: 0.35s window after the last arrival, 1.0s hard cap from the first.
  • Drain boundary force-flushes the buffer before consuming _pending_messages, so the timer never delays a follow-up turn — the agent finishing first cancels the timer.
  • Per-sender attribution preserved (shared sessions don't cross-merge).
  • Control commands (/stop, /new, /reset, /approve, clarify answers) bypass debounce.
  • busy_text_mode=interrupt preserves legacy behavior unchanged.

Mode interaction

Default pairing is busy_input_mode=interrupt + busy_text_mode=queue — text follow-ups silently queue without firing the busy ack or interrupting the running turn. Photo/media still take their existing path.

Env vars / config

Key Default
HERMES_GATEWAY_BUSY_TEXT_MODE / display.busy_text_mode queue
HERMES_GATEWAY_BUSY_TEXT_DEBOUNCE_SECONDS 0.35
HERMES_GATEWAY_BUSY_TEXT_HARD_CAP_SECONDS 1.0

Validation

  • 123/123 targeted tests pass across the 8 touched files (15 new debounce tests + 5 updated for new default)
  • 5813/5813 gateway suite passes locally
  • Clean cherry-pick onto current main, no conflicts
  • Single feature commit + AUTHOR_MAP entry

Closes #31235.

@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-f7e72d1a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9065 on HEAD, 9064 on base (🆕 +1)

🆕 New issues (1):

Rule Count
invalid-assignment 1
First entries
tests/gateway/test_active_session_text_merge.py:283: [invalid-assignment] invalid-assignment: Object of type `def _fake_start(event, session_key, *, interrupt_event=None) -> Unknown` is not assignable to attribute `_start_session_processing` of type `def _start_session_processing(self, event: MessageEvent, session_key: str, *, interrupt_event: Event | None = None) -> bool`

✅ Fixed issues: none

Unchanged: 4824 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

Comment thread gateway/platforms/base.py Fixed
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 24, 2026
CodeQL py/clear-text-logging-sensitive-data flagged the candidate-accept
debug log including event.text[:60]. Log text_len instead — sufficient for
debugging burst behavior without surfacing message contents.

Co-authored-by: Paulo Nascimento <pnascimento9596@gmail.com>
@teknium1 teknium1 merged commit 1bed4e8 into main May 24, 2026
23 checks passed
@teknium1 teknium1 deleted the hermes/hermes-f7e72d1a branch May 24, 2026 08:31
@teknium1

Copy link
Copy Markdown
Contributor Author

Infographic

PR #31341 chalkboard infographic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants