Skip to content

fix(agent): route compression count warning through _emit_status for TUI delivery#36922

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/compression-count-warning-tui
Open

fix(agent): route compression count warning through _emit_status for TUI delivery#36922
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/compression-count-warning-tui

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Routes the compression count warning (shown when a session is compressed 2+ times) through agent._emit_status() instead of agent._vprint(), fixing silent swallowing in TUI mode. Also stores the warning in agent._compression_warning for gateway replay.

Related Issue

Fixes #36908

Type of Change

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

Changes Made

  • agent/conversation_compression.py: Replace agent._vprint(force=True) with agent._compression_warning = msg + agent._emit_status(msg) in the if _cc >= 2 block, matching the pattern already used by the compression feasibility warning (lines 117-118, 231-232).
  • tests/agent/test_compression_count_warning.py: Add regression tests verifying (1) the warning block uses _emit_status and not _vprint, and (2) the warning is stored in _compression_warning for gateway replay.

How to Test

  1. Run pytest tests/agent/test_compression_count_warning.py -xvs — both tests should pass
  2. Run pytest tests/agent/test_context_compressor.py -xvs — all 91 existing tests should still pass
  3. Run pytest tests/run_agent/test_compression_feasibility.py -xvs — all 16 feasibility tests should still pass
  4. Verify the fix in TUI mode: hermes --tui, compress a session twice, confirm the "accuracy may degrade" warning appears in the TUI interface

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: agent/conversation_compression.py:compress_context — the _cc >= 2 warning block
  • Blast radius: LOW — single function, isolated warning path
  • Related patterns: Same _compression_warning + _emit_status pattern used at lines 117-118 and 231-232 in the same file for compression feasibility warnings

…TUI delivery

The compression count warning (shown when a session is compressed 2+
times) used agent._vprint() which writes to stdout. In TUI mode, the
Ink UI does not consume stdout, so the warning was silently swallowed.

This change routes the warning through agent._compression_warning +
agent._emit_status(), matching the pattern already used by the
compression feasibility warning (lines 117-118, 231-232). This ensures
delivery via status_callback to all platforms (CLI, TUI, Telegram,
Discord, etc.).

The warning is also stored in agent._compression_warning for gateway
replay via replay_compression_warning().

Fixes NousResearch#36908
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI: compression count warning (accuracy degrade) is silently swallowed

2 participants