hermes-agent/tests/cli
Teknium 8a6aa5882e
fix(cli): sync session_id after compression and preserve original end_reason (#12920)
After context compression (manual /compress or auto), run_agent's
_compress_context ends the current session and creates a new continuation
child session, mutating agent.session_id. The classic CLI held its own
self.session_id that never resynced, so /status showed the ended parent,
the exit-summary --resume hint pointed at a closed row, and any later
end_session() call (from /resume <other> or /branch) targeted the wrong
row AND overwrote the parent's 'compression' end_reason.

This only affected the classic prompt_toolkit CLI. The gateway path was
already fixed in PR #1160 (March 2026); --tui and ACP use different
session plumbing and were unaffected.

Changes:
- cli.py::_manual_compress — sync self.session_id from self.agent.session_id
  after _compress_context, clear _pending_title
- cli.py chat loop — same sync post-run_conversation for auto-compression
- cli.py hermes -q single-query mode — same sync so stderr session_id
  output points at the continuation
- hermes_state.py::end_session — guard UPDATE with 'ended_at IS NULL' so
  the first end_reason wins; reopen_session() remains the explicit
  escape hatch for re-ending a closed row

Tests:
- 3 new in tests/cli/test_manual_compress.py (split sync, no-op guard,
  pending_title behavior)
- 2 new in tests/test_hermes_state.py (preserve compression end_reason
  on double-end; reopen-then-re-end still works)

Closes #12483. Credits @steve5636 for the same-day bug report and
@dieutx for PR #3529 which proposed the CLI sync approach.
2026-04-20 01:48:20 -07:00
..
__init__.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_branch_command.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_approval_ui.py fix(cli): stop approval panel from clipping approve/deny off-screen (#11260) 2026-04-16 16:36:07 -07:00
test_cli_background_tui_refresh.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_browser_connect.py fix: /browser connect auto-launch uses dedicated profile dir (#6821) 2026-04-09 14:55:45 -07:00
test_cli_context_warning.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_copy_command.py feat: add /copy and /agents 2026-04-09 17:19:36 -05:00
test_cli_extension_hooks.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_file_drop.py fix(termux): add local image chat route 2026-04-09 16:24:53 -07:00
test_cli_image_command.py fix(termux): harden execute_code and mobile browser/audio UX 2026-04-09 16:24:53 -07:00
test_cli_init.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_interrupt_subagent.py fix: resolve CI test failures — add missing functions, fix stale tests (#9483) 2026-04-14 01:43:45 -07:00
test_cli_loading_indicator.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_mcp_config_watch.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_new_session.py fix(tests): resolve remaining CI failures — commit_memory_session, already_sent, timezone leak, session env (#10785) 2026-04-16 02:26:14 -07:00
test_cli_plan_command.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_prefix_matching.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_preloaded_skills.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_provider_resolution.py refactor: remove smart_model_routing feature (#12732) 2026-04-19 18:12:55 -07:00
test_cli_retry.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_save_config_value.py fix(config): preserve env refs when save_config rewrites config (#11892) 2026-04-17 19:03:26 -07:00
test_cli_secret_capture.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_skin_integration.py fix(termux): deepen browser, voice, and tui support 2026-04-09 16:24:53 -07:00
test_cli_status_bar.py fix(cli): use display width for wrapped spinner height 2026-04-18 14:34:05 -07:00
test_cli_status_command.py fix(profile): use existing get_active_profile_name() for /profile command 2026-04-15 17:52:03 -07:00
test_cli_tools_command.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_compress_focus.py feat: /compress <focus> — guided compression with focus topic (#8017) 2026-04-11 19:23:29 -07:00
test_cwd_env_respect.py fix: enforce config.yaml as sole CWD source + deprecate .env CWD vars + add hermes memory reset (#11029) 2026-04-16 06:48:33 -07:00
test_fast_command.py refactor: remove smart_model_routing feature (#12732) 2026-04-19 18:12:55 -07:00
test_gquota_command.py fix(cli): sanitize interactive command output 2026-04-19 01:16:34 -07:00
test_manual_compress.py fix(cli): sync session_id after compression and preserve original end_reason (#12920) 2026-04-20 01:48:20 -07:00
test_personality_none.py fix(gateway): use profile-aware Hermes paths in runtime hints 2026-04-15 17:52:03 -07:00
test_quick_commands.py fix(cli): sanitize interactive command output 2026-04-19 01:16:34 -07:00
test_reasoning_command.py test: update stale tests to match current code (#11963) 2026-04-17 21:35:30 -07:00
test_resume_display.py fix(cli): strip all reasoning tag variants from /resume recap 2026-04-18 19:19:24 -07:00
test_session_boundary_hooks.py fix: add gateway coverage for session boundary hooks, move test to tests/cli/ 2026-04-08 04:27:34 -07:00
test_stream_delta_think_tag.py fix(streaming): prevent <think> in prose from suppressing response output 2026-04-09 22:16:36 -07:00
test_surrogate_sanitization.py fix(surrogates): sanitize reasoning/reasoning_content/reasoning_details fields (#11628) 2026-04-17 13:30:47 -07:00
test_tool_progress_scrollback.py fix(cli): restore stacked tool progress scrollback in TUI (#8201) 2026-04-11 23:22:34 -07:00
test_worktree.py fix: aggressive worktree and branch cleanup to prevent accumulation (#6134) 2026-04-08 04:44:49 -07:00
test_worktree_security.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00