Skip to content

fix(compression): skip empty post-handoff summary windows - #59526

Closed
WOLIKIMCHENG wants to merge 1 commit into
NousResearch:mainfrom
WOLIKIMCHENG:fix-empty-post-handoff-summary-window
Closed

fix(compression): skip empty post-handoff summary windows#59526
WOLIKIMCHENG wants to merge 1 commit into
NousResearch:mainfrom
WOLIKIMCHENG:fix-empty-post-handoff-summary-window

Conversation

@WOLIKIMCHENG

Copy link
Copy Markdown

What does this PR do?

Skips context summary generation when the latest handoff summary leaves no new turns after compression boundary adjustment.

This avoids calling _generate_summary([]) / the configured context engine with an empty input window, which currently produces a noisy compression-aborted warning while preserving the transcript unchanged.

Related Issue

Fixes #59496

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • agent/context_compressor.py: add a post-handoff empty-window guard that records ineffective compression and returns without calling _generate_summary.
  • tests/agent/test_context_compressor_summary_continuity.py: add a regression test proving _generate_summary is not called when the latest handoff consumes the compression window.

How to Test

  1. python -m pytest tests/agent/test_context_compressor_summary_continuity.py -q
  2. python -m pytest tests/agent/test_context_compressor_cross_session_guard.py -q
  3. python -m pytest tests/agent/test_context_compressor.py tests/run_agent/test_infinite_compaction_loop.py -q
  4. python -m py_compile agent/context_compressor.py tests/agent/test_context_compressor_summary_continuity.py
  5. git diff --check -- agent/context_compressor.py tests/agent/test_context_compressor_summary_continuity.py

Notes:

  • scripts/run_tests.sh --files ... could not run locally because this checkout has no .venv or venv.
  • ruff was not available locally.

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: Linux, Python 3.10.12

Documentation & Housekeeping

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

Screenshots / Logs

N/A — covered by regression tests.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P3 Low — cosmetic, nice to have labels Jul 6, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression fix. Current main still recomputes turns_to_summarize after finding a handoff summary (agent/context_compressor.py:3105-3108) and then calls _generate_summary(...) unconditionally (agent/context_compressor.py:3139-3141). That directly permits the zero-turn window reported in #59496.

The proposed early return mirrors the established no-compressible-window accounting at agent/context_compressor.py:3073-3089, preserves the transcript, and prevents the unnecessary context-engine invocation. The added test exercises the post-handoff boundary rather than merely asserting static source shape.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/compression Context compression and continuation sessions labels Jul 15, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via salvage PR #70251 with your commit cherry-picked and authorship preserved — thanks @WOLIKIMCHENG! Your empty-post-handoff-window guard (with the regression test) now ships on main; the only adaptation was routing the ineffective-strike through _record_ineffective_compression_verdict() for the durable breaker persistence that landed after this PR was opened. @ms-alan's #59737 independently identified the same fix and is credited there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compression Context compression and continuation sessions comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Context compression calls context engine with empty window after summary boundary adjustment

3 participants