fix(cli): preserve chat -q answer by gating exit-summary screen clear (salvage #53025) - #60926
Merged
Conversation
…#53009) In single-query (-q) mode, the assistant's final answer was printed and then immediately erased by _print_exit_summary() — which unconditionally called _clear_terminal_on_exit() (ESC[3J ESC[2J ESC[H]). The answer was present in the session store but invisible in the terminal. The clear is only needed for interactive TUI teardown (#38928) where prompt_toolkit chrome must be cleaned up. Add a clear_screen parameter to _print_exit_summary() (default True, preserving interactive behavior) and pass False from the single-query call site so the answer stays visible above the exit summary. Regression tests cover: - clear_screen=True (default) calls _clear_terminal_on_exit() - clear_screen=False skips the clear - Single-query -q path passes False end-to-end - Interactive path still clears (preserving #38928)
tonydwb
reviewed
Jul 8, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment (172 additions — preserve chat -q answer by gating exit-summary screen clear)
Scope
Fixes a bug where the -q answer would be cleared by the exit-summary screen. Salvage of #53025.
Observations
- Adds gating logic to prevent exit-summary screen from clearing the answer.
- The
print()on line 43 appears in a CLI context for user feedback — appropriate. - Salvage PR referencing #53025 — good for reviewer context.
Recommendation
Looks reasonable. Human reviewer should confirm the salvage relationship and the fix scope.
Reviewed by Hermes Agent
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.
Summary
Salvage of #53025 by @Tranquil-Flow —
hermes chat -q "<prompt>"no longer wipes the assistant's answer off the screen right after printing it. Fixes #53009.Root cause: the single-query path calls
_print_exit_summary()immediately aftercli.chat(query), and that unconditionally ran_clear_terminal_on_exit()(ESC[3J ESC[2J ESC[Hon a TTY) — erasing the just-printed answer and leaving only the exit summary.Changes
cli.py:_print_exit_summary(clear_screen=True)— the single-query path passesclear_screen=False; interactive-exit behavior ([Bug]: Hermes Agent does not cleanly hand control back to CLI after session ends #38252) is unchangedtests/cli/test_chat_q_exit_clear.py: new regression tests (contributor's)tests/cli/test_single_query_session_finalize.py— FakeCLI stub updated for the new kwarg (was TypeError-ing in the PR's CI)Validation
tests/cli/test_chat_q_exit_clear.py+test_single_query_session_finalize.pyContributor commit cherry-picked with authorship preserved (rebase-merge).
Infographic