Skip to content

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

Merged
teknium1 merged 1 commit into
mainfrom
salvage/3243-compact-alias
Jul 2, 2026
Merged

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

Conversation

@teknium1

@teknium1 teknium1 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of #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 #44794/#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 #3243
Closes #3240

Nous Research

…ess (#3243 salvage)

Salvaged from PR #3243 by @Mibayy, reimplemented against current main
(the original diff targeted a removed gateway/run.py handler).

- /compact is now a first-class alias of /compress (CLI, gateway,
  Telegram/Slack/Discord command lists, autocomplete) — also fixes the
  dangling '/compact' references in gateway error messages
  (gateway/run.py context-exhausted banners).
- --preview / --dry-run: report what WOULD be compressed (message
  counts, token estimate, 'here [N]' boundary) without touching the
  transcript. Flags coexist with the existing 'here [N]' / focus-topic
  args on both the CLI and gateway surfaces via shared pure helpers in
  hermes_cli/partial_compress.py.
- --aggressive (LLM-free hard truncation) is intentionally NOT
  implemented: it would need its own transcript-persistence branch
  outside the guarded _compress_context rotation machinery (#44794
  data-loss class). The flag is recognized and returns an explanatory
  message pointing at '/compress here [N]' and /undo instead of being
  mis-parsed as a focus topic.
- locales: gateway.compress.aggressive_unsupported added to all 16
  catalogs (parity test enforced).
- release.py: AUTHOR_MAP entry for contributor credit.
@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels Jul 2, 2026
@teknium1
teknium1 merged commit ce9aa86 into main Jul 2, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage/3243-compact-alias branch July 2, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Enhanced Context Compaction Command (/compact)

2 participants