hermes - ✅(Solved) Fix [Bug]: 自动生成多条空对话记录导致对话记录紊乱 [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#19767Fetched 2026-05-05 06:05:17
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

PR fix notes

PR #19983: fix(tui): drop empty submissions left over after stripping leaked terminal bytes

Description (problem / solution / changelog)

What does this PR do?

Addresses #19767. WSL2 + Windows Terminal: dragging the window triggers a SIGWINCH storm where prompt_toolkit's DSR (cursor-position) queries and SGR mouse reports leak into stdin. The trailing M of mouse-report sequences parses as Ctrl+M (= Enter), which submits a buffer containing only the leaked bytes — one ghost record per leaked sequence, accumulating to the dozen-plus empty conversation records the reporter screenshots show.

The existing strip helpers (_strip_leaked_bracketed_paste_wrappers, _strip_leaked_terminal_responses_with_meta) already clean those bytes from the submitted buffer, but process_loop did not re-check emptiness afterward, so the empty payload reached _print_user_message_preview and rendered a divider + bullet with no text.

This PR adds the missing post-strip emptiness guard at the existing chokepoint. The fix is a defensive net at the last common point before the preview prints, so it covers any leak path that collapses to empty after stripping — not just the SGR-mouse-as-Ctrl+M mechanism.

Related Issue

Addresses #19767

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • cli.py — add _is_empty_after_terminal_noise_strip(text, has_attachments) helper (17 lines) + a guard call in process_loop immediately after the existing strip pass (2 lines + comment). has_attachments is honored so image-only submissions still pass through.
  • tests/cli/test_cli_resize_empty_record.py — new regression file:
    • TestEmptyAfterTerminalNoiseStrip (6 cases) — pure-function guard semantics: real text preserved, empty/whitespace dropped, has_attachments=True keeps blank-text payloads alive, non-string inputs handled.
    • TestResizeStormCollapsesToEmpty (6 cases) — drives real leaked CPR / SGR-mouse / bracketed-paste sequences through the same two-step strip pipeline process_loop runs, asserts the guard fires; one positive case proves real text wedged between leaked bytes survives.

How to Test

  1. Run pytest tests/cli/test_cli_resize_empty_record.py -q → 12 new tests pass.
  2. Adjacent regression check: pytest tests/cli/test_cli_force_redraw.py tests/cli/test_cli_terminal_response_sanitizer.py tests/cli/test_cli_bracketed_paste_sanitizer.py -q → 32 pre-existing pass.
  3. Without the source fix, the new test errors at import (the helper doesn't exist) — true regression test.
  4. Manual reproduction (WSL2 + Windows Terminal): start hermes, drag the terminal window to resize. Before this PR: dozens of empty bullet records; after: window resizes silently with no transcript change.

Caveat: WSL2-only bug, could not reproduce locally. Diagnosis inferred from prior maintainer comment naming the SGR-mouse-as-Ctrl+M leak path and from reading the existing leak-strip code.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/cli/ -q -k "resize or terminal_response or bracketed_paste" and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS darwin-arm64 (cannot test WSL2 directly; defensive net at chokepoint)

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (helper is internal; behavior matches the existing strip-pipeline contract)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) — yes, the guard is platform-neutral; WSL2 reporters affected most because their terminal emits the leak under SIGWINCH storms
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Changed files

  • cli.py (modified, +33/-1)
  • tests/cli/test_cli_resize_empty_record.py (added, +98/-0)

Code Example

https://paste.rs/4RDfb

---

https://paste.rs/S3XDc
RAW_BUFFERClick to expand / collapse

Bug Description

环境:WSL2 + Ubuntu 22.04 + Windows Terminal 触发条件:拖动窗口改变大小 现象:自动生成多条空对话记录 原因猜测:未正确处理 SIGWINCH 信号

Steps to Reproduce

拖动窗口大小

Expected Behavior

仅改变窗口大小,里面内容无变化

Actual Behavior

里面自动添加了多条空对话记录,有时多大十几条,二十几条占满窗口

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

https://paste.rs/4RDfb

Operating System

ubuntu 22.04

Python Version

3.11.15

Hermes Version

V0.12.0

Additional Logs / Traceback (optional)

https://paste.rs/S3XDc

Root Cause Analysis (optional)

未正确处理 SIGWINCH 信号

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The issue can likely be fixed by properly handling the SIGWINCH signal in the CLI interactive chat component.

Guidance

  • Investigate how the SIGWINCH signal is currently being handled in the code and identify areas for improvement.
  • Review the provided debug report and additional logs to understand the sequence of events leading to the generation of empty dialogue records.
  • Consider implementing a signal handler to catch and process the SIGWINCH signal, potentially ignoring or filtering out unnecessary resize events.
  • Test the application with different window resize scenarios to verify the fix and ensure it does not introduce new issues.

Example

No code example is provided due to lack of specific code context in the issue.

Notes

The provided information suggests a potential issue with signal handling, but without access to the codebase, it's difficult to provide a precise fix. The solution may involve modifying the existing signal handling mechanism or adding a new one.

Recommendation

Apply workaround: Implement a custom signal handler to properly process the SIGWINCH signal, as the current handling seems to be causing the generation of empty dialogue records.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: 自动生成多条空对话记录导致对话记录紊乱 [1 pull requests, 1 comments, 2 participants]