Skip to content

feat(gateway): background process notification modes + fix spinner line spam - #840

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-98b7f9b9
Mar 10, 2026
Merged

feat(gateway): background process notification modes + fix spinner line spam#840
teknium1 merged 2 commits into
mainfrom
hermes/hermes-98b7f9b9

Conversation

@teknium1

@teknium1 teknium1 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Two changes on this branch:

1. Configurable background process watcher notifications

Adds display.background_process_notifications config option to control how chatty the gateway process watcher is when using terminal(background=true, check_interval=...) from Telegram/Discord/etc.

Modes:

  • all — running-output updates + final message (default, preserves current behavior)
  • result — only the final completion message
  • error — only the final message when exit code != 0
  • off — no watcher messages at all

Also supports HERMES_BACKGROUND_NOTIFICATIONS env var override.

Inspired by @PeterFile's PR #593 (stale branch, reimplemented on current main). Closes #592.

2. Fix spinner line spam under prompt_toolkit's patch_stdout

The KawaiiSpinner animation would occasionally spam dozens of duplicate lines instead of overwriting in-place with \r. Root cause: prompt_toolkit's StdoutProxy processes each flush() as a separate run_in_terminal() call — when the write thread is slow (busy event loop during long tool executions like execute_code or terminal), each \r frame gets its own call, breaking the overwrite semantics.

Fix: Rate-limit flush() calls to every 0.4s. Between flushes, \r-frame writes accumulate in the buffer. Each flush batches ~3 frames into one write, guaranteeing the \r collapse always works.

Changes

  • gateway/run.py — new _load_background_notifications_mode() + updated _run_process_watcher()
  • agent/display.py — rate-limited spinner flush to prevent line spam
  • cli-config.yaml.example — documented new config option
  • AGENTS.md — added background process notifications section
  • 12 new tests for notification modes

Test plan

pytest tests/ -q  # 2810 passed

Add display.background_process_notifications config option to control
how chatty the gateway process watcher is when using
terminal(background=true, check_interval=...) from messaging platforms.

Modes:
  - all:    running-output updates + final message (default, current behavior)
  - result: only the final completion message
  - error:  only the final message when exit code != 0
  - off:    no watcher messages at all

Also supports HERMES_BACKGROUND_NOTIFICATIONS env var override.

Includes 12 tests (5 config loading + 7 watcher behavior).

Inspired by @PeterFile's PR #593. Closes #592.
…atch_stdout

The KawaiiSpinner animation would occasionally spam dozens of duplicate
lines instead of overwriting in-place with \r. This happened because
prompt_toolkit's StdoutProxy processes each flush() as a separate
run_in_terminal() call — when the write thread is slow (busy event loop
during long tool executions), each \r frame gets its own call, and the
terminal layout save/restore between calls breaks the \r overwrite
semantics.

Fix: rate-limit flush() calls to at most every 0.4s. Between flushes,
\r-frame writes accumulate in StdoutProxy's buffer. When flushed, they
concatenate into one string (e.g. \r frame1 \r frame2 \r frame3) and
are written in a single run_in_terminal() call where \r works correctly.

The spinner still animates (flush ~2.5x/sec) but each flush batches
~3 frames, guaranteeing the \r collapse always works. Most visible
with execute_code and terminal tools (3+ second executions).
@teknium1 teknium1 changed the title feat(gateway): configurable background process watcher notifications feat(gateway): background process notification modes + fix spinner line spam Mar 10, 2026
@teknium1
teknium1 merged commit 2a062e2 into main Mar 10, 2026
1 check failed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…x spinner line spam

- feat(gateway): configurable background_process_notifications (off/result/error/all)
- fix(display): rate-limit spinner flushes to prevent line spam under patch_stdout

Background notifications inspired by @PeterFile (PR NousResearch#593).
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…x spinner line spam

- feat(gateway): configurable background_process_notifications (off/result/error/all)
- fix(display): rate-limit spinner flushes to prevent line spam under patch_stdout

Background notifications inspired by @PeterFile (PR NousResearch#593).
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…x spinner line spam

- feat(gateway): configurable background_process_notifications (off/result/error/all)
- fix(display): rate-limit spinner flushes to prevent line spam under patch_stdout

Background notifications inspired by @PeterFile (PR NousResearch#593).
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.

[Feature]: configurable gateway background process watcher notifications

1 participant