Skip to content

feat: display previous messages when resuming a session in CLI#734

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f8d56335
Mar 9, 2026
Merged

feat: display previous messages when resuming a session in CLI#734
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f8d56335

Conversation

@teknium1

@teknium1 teknium1 commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #719 — when resuming a session via --continue or --resume, displays a compact recap of previous conversation messages in a Rich panel before the input prompt.

Before: User sees only a one-line status and has zero context about what was discussed.
After: A styled "Previous Conversation" panel shows user messages, assistant responses, and tool call summaries immediately upon resume.

What Changed

cli.py (3 files, +700 lines)

New methods on HermesCLI:

  • _preload_resumed_session() — Loads session history from SQLite early (called from run() before the banner), so the user sees history immediately. Prints the one-liner status message. Returns True if history was loaded. _init_agent() now skips the DB round-trip when history is already populated.
  • _display_resumed_history() — Renders a compact conversation recap using a Rich Panel:
    • User messages shown with gold bullet , truncated at 300 chars
    • Assistant responses shown with green diamond , truncated at 200 chars / 3 lines
    • Tool calls collapsed to count + tool names (e.g. [3 tool calls: terminal, web_search])
    • System messages and tool results hidden
    • <REASONING_SCRATCHPAD> blocks stripped from assistant text
    • Pure-reasoning messages (no visible output after stripping) skipped entirely
    • Capped at last 10 exchanges with ... N earlier messages ... indicator
    • Dim/muted styling so recap is visually distinct from the active conversation

Integration in run():

  • After show_banner(), if self._resumed: calls _preload_resumed_session() then _display_resumed_history()
  • History is displayed before the user types anything

Instance variable:

  • self.resume_display — captured from config at init time (like self.compact)

hermes_cli/config.py

  • Added display.resume_display to DEFAULT_CONFIG with default "full"

Config option

display:
  resume_display: full    # full | minimal
  • full (default) — show previous messages panel
  • minimal — current behavior (just the one-liner)

Test Plan

27 new tests in tests/test_resume_display.py:

  • Display tests (17): user/assistant rendering, system/tool message hiding, tool call summaries, message truncation, multiline truncation, large history truncation indicator, multimodal content, empty history, minimal config, panel title, reasoning stripping, pure-reasoning skip, mixed text+tool_calls
  • Preload tests (7): not-resumed guard, no-DB guard, session-not-found, no-messages, successful load, DB reopening, singular grammar
  • Integration (1): _init_agent() skips DB when preloaded
  • Config (2): DEFAULT_CONFIG and cli defaults include resume_display
$ python -m pytest tests/test_resume_display.py -v
27 passed in 0.67s

$ python -m pytest tests/ -q
2371 passed, 5 skipped, 23 deselected in 113s

Interactive verification: Tested with python cli.py --resume <session_id> against real sessions with tool calls, reasoning content, and context summaries. Display renders cleanly.

Example Output

╭─────────────────────────── Previous Conversation ────────────────────────────╮
│   ● You: Read all 4 GitHub issues (#501, #502, #503, #504) from              │
│ NousResearch/hermes-agent in full. For each issue, extract: (1) the exact    │
│ scope/phases...                                                              │
│   ◆ Hermes: [4 tool calls: terminal]                                         │
│   ◆ Hermes: All 4 issues read successfully. Here is the structured analysis: │
│             ================================================================ │
│ ======== ...                                                                 │
╰──────────────────────────────────────────────────────────────────────────────╯

Closes #719

teknium1 added 2 commits March 8, 2026 17:45
When resuming a session via --continue or --resume, show a compact recap
of the previous conversation inside a Rich panel before the input prompt.
This gives users immediate visual context about what was discussed.

Changes:
- Add _preload_resumed_session() to load session history early (in run(),
  before banner) so _init_agent() doesn't need a separate DB round-trip
- Add _display_resumed_history() that renders a formatted recap panel:
  * User messages shown with gold bullet (truncated at 300 chars)
  * Assistant responses shown with green diamond (truncated at 200 chars / 3 lines)
  * Tool calls collapsed to count + tool names
  * System messages and tool results hidden
  * <REASONING_SCRATCHPAD> blocks stripped from display
  * Pure-reasoning messages (no visible output) skipped entirely
  * Capped at last 10 exchanges with 'N earlier messages' indicator
  * Dim/muted styling distinguishes recap from active conversation
- Add display.resume_display config option: 'full' (default) or 'minimal'
- Store resume_display as instance variable (like compact) for testability
- 27 new tests covering all display scenarios, config, and edge cases

Closes #719
… docs

- sessions.md: New 'Conversation Recap on Resume' subsection with visual
  example, feature bullet points, and config snippet
- cli.md: New 'Session Resume Display' subsection with cross-reference
- configuration.md: Add resume_display to display settings YAML block
- AGENTS.md: Add _preload_resumed_session() and _display_resumed_history()
  to key components, add UX note about resume panel
@teknium1 teknium1 merged commit 0efbb13 into main Mar 9, 2026
1 check passed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…8d56335

feat: display previous messages when resuming a session in CLI
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…8d56335

feat: display previous messages when resuming a session in CLI
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…8d56335

feat: display previous messages when resuming a session in CLI
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…8d56335

feat: display previous messages when resuming a session in CLI
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: Display Previous Messages When Resuming a Session in CLI TUI

1 participant