fix(agent): route compression count warning through _emit_status for TUI delivery#36922
Open
liuhao1024 wants to merge 1 commit into
Open
fix(agent): route compression count warning through _emit_status for TUI delivery#36922liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Routes the compression count warning (shown when a session is compressed 2+ times) through
agent._emit_status()instead ofagent._vprint(), fixing silent swallowing in TUI mode. Also stores the warning inagent._compression_warningfor gateway replay.Related Issue
Fixes #36908
Type of Change
Changes Made
agent/conversation_compression.py: Replaceagent._vprint(force=True)withagent._compression_warning = msg+agent._emit_status(msg)in theif _cc >= 2block, 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_statusand not_vprint, and (2) the warning is stored in_compression_warningfor gateway replay.How to Test
pytest tests/agent/test_compression_count_warning.py -xvs— both tests should passpytest tests/agent/test_context_compressor.py -xvs— all 91 existing tests should still passpytest tests/run_agent/test_compression_feasibility.py -xvs— all 16 feasibility tests should still passhermes --tui, compress a session twice, confirm the "accuracy may degrade" warning appears in the TUI interfaceChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/conversation_compression.py:compress_context— the_cc >= 2warning block_compression_warning + _emit_statuspattern used at lines 117-118 and 231-232 in the same file for compression feasibility warnings