Skip to content

feat(commands): /compact alias + preview flags for /compress (#3243 salvage) - #834

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-57029
Jul 2, 2026
Merged

feat(commands): /compact alias + preview flags for /compress (#3243 salvage)#834
hashbender merged 1 commit into
mainfrom
mirror/pr-57029

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

Salvage of NousResearch#3243 by @Mibayy — adds /compact as a first-class alias of /compress plus --preview/--dry-run flags on both the CLI and gateway surfaces; reimplemented against current main because the original diff targeted a removed gateway/run.py handler.

Changes

  • hermes_cli/commands.pycompress CommandDef gains aliases=("compact",); args_hint/description document the new flags. /compact now resolves everywhere (CLI, gateway, Telegram/Slack/Discord command lists, autocomplete) — and fixes the dangling /compact references in main's context-exhausted error banners (gateway/run.py:2513, :11707).
  • hermes_cli/partial_compress.py — new pure helpers shared by both surfaces: extract_compress_flags() (strips --preview/--dry-run/--aggressive so they coexist with the existing here [N] / --keep N / focus-topic args) and summarize_compress_preview() (message counts, token estimate, here boundary — side-effect-free).
  • cli.py _manual_compress--preview/--dry-run print the report and return without compressing; --aggressive prints an explanatory redirect (see below).
  • gateway/slash_commands.py _handle_compress_command — same semantics; the preview path returns before any AIAgent construction or transcript write (no provider/API key needed).
  • locales/*.yamlgateway.compress.aggressive_unsupported added to all 16 catalogs (parity test enforced).
  • scripts/release.pyAUTHOR_MAP entry for contributor credit.
  • Teststests/cli/test_compress_flags.py (17 tests: alias resolution, flag extraction, preview report shape/purity) and tests/gateway/test_compress_preview.py (7 async tests: preview/dry-run/aggressive paths assert rewrite_transcript/update_session are never called).

Dropped: --aggressive (deliberately)

The original PR's --aggressive path called session_store.rewrite_transcript directly to hard-truncate to the last 4 messages. On current main that's exactly the pattern that caused the NousResearch#44794/NousResearch#39704 permanent-data-loss class — manual transcript rewrites outside the guarded _compress_context rotation/persistence machinery (rotation vs. in-place vs. failed-rotation handling, session repointing ordering, soft-delete audit trail). Implementing it safely would mean a parallel persistence branch on both surfaces; /compress here [N] and /undo already cover the use case. Instead of silently mis-parsing --aggressive as a focus topic, both surfaces recognize the flag and return an explanatory message pointing at those alternatives (--aggressive --dry-run still shows the preview plus the note).

Validation

Check Result
scripts/run_tests.sh tests/cli/test_compress_flags.py tests/cli/test_partial_compress.py tests/gateway/test_compress_preview.py tests/gateway/test_compress_command.py tests/agent/test_i18n.py tests/hermes_cli/test_commands.py -q 259 passed, 0 failed
scripts/run_tests.sh tests/gateway/test_gateway_command_help.py tests/gateway/test_gateway_command_line_matcher.py tests/gateway/test_discord_slash_commands.py -q (alias slot/parity) 225 passed, 0 failed
ruff check on all touched files All checks passed
Locale key parity (aggressive_unsupported in all 16 catalogs)

Infographic

infographic

Closes NousResearch#3243
Closes NousResearch#3240

Nous Research


Mirror-of: NousResearch#57029
NousResearch#57029

@hashbender
hashbender merged commit 0a757a3 into main Jul 2, 2026
2 checks passed
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]: Enhanced Context Compaction Command (/compact)

1 participant