Skip to content

fix(compaction): show status message + re-emit context pressure bar at 95%#5963

Closed
KUSH42 wants to merge 2 commits into
NousResearch:mainfrom
KUSH42:fix/compaction-feedback
Closed

fix(compaction): show status message + re-emit context pressure bar at 95%#5963
KUSH42 wants to merge 2 commits into
NousResearch:mainfrom
KUSH42:fix/compaction-feedback

Conversation

@KUSH42

@KUSH42 KUSH42 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Two small UX fixes for context compaction feedback:

  1. Missing status message during compression: When auto-compaction fired, the agent went silent for 10–30 s while the context summarisation LLM call ran — no spinner, no message. A ⟳ compacting context… line is now printed before _compress_context() so the user knows what's happening.

  2. Context pressure bar only showed once: The progress bar was gated on a boolean _context_pressure_warned that latched True at 85% and never re-fired. Users climbing from 88% → 97% never saw the bar update or change colour (orange → red). The bool is replaced with a float _context_pressure_warned_at that tracks the highest threshold already shown (0.85 or 0.95), allowing a second emit at the critical 95% tier.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • run_agent.py: replace _context_pressure_warned: bool with _context_pressure_warned_at: float; add two-tier warning logic (0.85, 0.95); print ⟳ compacting context… before compression fires
  • tests/test_context_pressure.py: update two existing tests for renamed field; add test_flag_reemits_at_95 and test_flag_no_double_emit_same_level

How to Test

  1. Run a long session until context reaches ~85% of the compaction threshold — verify the orange pressure bar appears
  2. Continue until ~95% — verify the bar re-emits in red
  3. Continue until compaction fires — verify ⟳ compacting context… is printed before the next prompt appears
  4. pytest tests/test_context_pressure.py -q — all 25 tests pass

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Ubuntu 24.04

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

- Print "⟳ compacting context…" before _compress_context() fires so
  users aren't staring at a frozen prompt during the LLM summarization
  call (which can take 10–30 s silently).

- Replace bool _context_pressure_warned with float
  _context_pressure_warned_at so the context pressure bar re-emits at
  the 95% threshold even after already firing at 85%.  Previously the
  once-only gate meant users never saw the bar change from orange→red
  as context climbed from 88% to 97%.

- Add tests: flag re-emits at 95%, no double-emit at same level, field
  initialises to 0.0 and resets to 0.0 after successful compression.
… case

Previous test only verified the happy path (compression brings tokens below
85% → flag resets). Add test_flag_not_reset_when_compression_insufficient
to verify the flag is preserved when post-compression tokens remain >= 85%
of threshold (e.g. fat system prompt dominates the budget).
@blasai1739217-cmyk

Copy link
Copy Markdown

Friendly bump on this PR in case it fell through the cracks \u2014 would love a review when someone has a minute. Thanks!

teknium1 added a commit that referenced this pull request Apr 9, 2026
Combines the approaches from PR #6309 (duan78) and PR #5963 (KUSH42):

Tiered warnings (from #5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from #6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes #6309. Fixes #5963.
@teknium1 teknium1 closed this in 54db7cb Apr 9, 2026
saxster pushed a commit to saxster/hermes-agent that referenced this pull request Apr 9, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
Tommyeds pushed a commit to Tommyeds/hermes-agent that referenced this pull request Apr 12, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…earch#6411)

Combines the approaches from PR NousResearch#6309 (duan78) and PR NousResearch#5963 (KUSH42):

Tiered warnings (from NousResearch#5963):
- Replaces boolean _context_pressure_warned with float _context_pressure_warned_at
- Fires at 85% (orange) and re-fires at 95% (red/critical)
- Adds 'compacting context...' status message before compression

Gateway dedup (from NousResearch#6309):
- Class-level dict _context_pressure_last_warned survives across AIAgent
  instances (gateway creates a new instance per message)
- 5-minute cooldown per session prevents warning spam
- Higher-tier warnings bypass the cooldown (85% → 95% always fires)
- Compression reset clears the dedup entry for the session
- Stale entries evicted (older than 2x cooldown) to prevent memory leak

Does NOT inject into messages — purely user-facing via _safe_print (CLI)
and status_callback (gateway). Zero prompt cache impact.

Fixes NousResearch#6309. Fixes NousResearch#5963.
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.

2 participants