feat(commands): /compact alias + preview flags for /compress (#3243 salvage) - #57029
Merged
Conversation
…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.
This was referenced Jul 2, 2026
This was referenced Jul 2, 2026
Closed
1 task
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 #3243 by @Mibayy — adds
/compactas a first-class alias of/compressplus--preview/--dry-runflags on both the CLI and gateway surfaces; reimplemented against current main because the original diff targeted a removedgateway/run.pyhandler.Changes
hermes_cli/commands.py—compressCommandDef gainsaliases=("compact",);args_hint/description document the new flags./compactnow resolves everywhere (CLI, gateway, Telegram/Slack/Discord command lists, autocomplete) — and fixes the dangling/compactreferences 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/--aggressiveso they coexist with the existinghere [N]/--keep N/ focus-topic args) andsummarize_compress_preview()(message counts, token estimate,hereboundary — side-effect-free).cli.py_manual_compress—--preview/--dry-runprint the report and return without compressing;--aggressiveprints an explanatory redirect (see below).gateway/slash_commands.py_handle_compress_command— same semantics; the preview path returns before anyAIAgentconstruction or transcript write (no provider/API key needed).locales/*.yaml—gateway.compress.aggressive_unsupportedadded to all 16 catalogs (parity test enforced).scripts/release.py—AUTHOR_MAPentry for contributor credit.tests/cli/test_compress_flags.py(17 tests: alias resolution, flag extraction, preview report shape/purity) andtests/gateway/test_compress_preview.py(7 async tests: preview/dry-run/aggressive paths assertrewrite_transcript/update_sessionare never called).Dropped:
--aggressive(deliberately)The original PR's
--aggressivepath calledsession_store.rewrite_transcriptdirectly 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_contextrotation/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/undoalready cover the use case. Instead of silently mis-parsing--aggressiveas a focus topic, both surfaces recognize the flag and return an explanatory message pointing at those alternatives (--aggressive --dry-runstill shows the preview plus the note).Validation
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 -qscripts/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)ruff checkon all touched filesaggressive_unsupportedin all 16 catalogs)Infographic
Closes #3243
Closes #3240
Nous Research