Skip to content

feat: /compress <focus> — guided compression with focus topic#8017

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-07b02ce7
Apr 12, 2026
Merged

feat: /compress <focus> — guided compression with focus topic#8017
teknium1 merged 1 commit into
mainfrom
hermes/hermes-07b02ce7

Conversation

@teknium1

@teknium1 teknium1 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an optional focus topic to /compress: typing /compress database schema guides the summariser to preserve information related to the focus topic (60-70% of summary budget) while compressing everything else more aggressively.

Works identically on both CLI and all gateway platforms (Telegram, Discord, etc.).

Usage

/compress                     # standard compression (unchanged behavior)
/compress database schema     # preserve DB schema details, compress rest aggressively
/compress authentication flow # preserve auth details, compress rest aggressively

Implementation

  • context_compressor.py: focus_topic parameter on _generate_summary() and compress(); appends a FOCUS TOPIC guidance block to the LLM summarisation prompt
  • run_agent.py: focus_topic parameter on _compress_context(), passed through to the compressor
  • cli.py: _manual_compress() extracts focus topic from command string; preserves existing manual_compression_feedback integration (no regression from feat: /context command + /compress focus — inspired by Claude Code #7459)
  • gateway/run.py: _handle_compress_command() extracts focus from event args — full gateway parity
  • commands.py: args_hint="[focus topic]" on /compress CommandDef

What's NOT changed

  • No changes to prompt caching
  • No changes to message flow invariants
  • /compress without arguments works exactly as before
  • All existing compression feedback (manual_compression_feedback module) preserved

Test results

197 passed — all compression, CLI, commands, and gateway tests

15 new tests across:

  • tests/cli/test_compress_focus.py — CLI focus extraction and passthrough
  • tests/agent/test_compress_focus.py — compressor prompt injection
  • tests/gateway/test_compress_focus.py — gateway focus extraction and passthrough

Salvaged from PR #7459. Inspired by Claude Code's /compact <focus>.

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR #7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
@teknium1 teknium1 merged commit a0a02c1 into main Apr 12, 2026
4 of 6 checks passed
@teknium1 teknium1 deleted the hermes/hermes-07b02ce7 branch April 12, 2026 02:23
Tommyeds pushed a commit to Tommyeds/hermes-agent that referenced this pull request Apr 12, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…search#8017)

Adds an optional focus topic to /compress: `/compress database schema`
guides the summariser to preserve information related to the focus topic
(60-70% of summary budget) while compressing everything else more aggressively.
Inspired by Claude Code's /compact <focus>.

Changes:
- context_compressor.py: focus_topic parameter on _generate_summary() and
  compress(); appends FOCUS TOPIC guidance block to the LLM prompt
- run_agent.py: focus_topic parameter on _compress_context(), passed through
  to the compressor
- cli.py: _manual_compress() extracts focus topic from command string,
  preserves existing manual_compression_feedback integration (no regression)
- gateway/run.py: _handle_compress_command() extracts focus from event args
  and passes through — full gateway parity
- commands.py: args_hint="[focus topic]" on /compress CommandDef

Salvaged from PR NousResearch#7459 (CLI /compress focus only — /context command deferred).
15 new tests across CLI, compressor, and gateway.
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.

1 participant