fix(compression): notify gateway users when summary generation fails - #16333
Closed
iamagenius00 wants to merge 5 commits into
Closed
fix(compression): notify gateway users when summary generation fails#16333iamagenius00 wants to merge 5 commits into
iamagenius00 wants to merge 5 commits into
Conversation
When auxiliary compression's summary LLM call fails (e.g. model 404, auxiliary model misconfigured), the compressor still drops the selected turns and inserts a static fallback placeholder — the dropped context is unrecoverable. Previously the only signal of this was a WARNING in agent.log. Gateway users (Telegram/Discord/etc.) had no way to know context was lost because the existing _emit_warning path requires a status_callback, and the gateway hygiene path uses a temporary _hyg_agent with quiet_mode=True and no callback wired up. Changes: - ContextCompressor: track _last_summary_fallback_used and _last_summary_dropped_count on each compress() call. Cleared at the start of compress() and on session reset. - gateway/run.py hygiene: after auto-compress, inspect the temp agent's compressor; if fallback was used, send a visible⚠️ warning to the user via the platform adapter (TG/Discord/etc.) including dropped count and the underlying error. - gateway/run.py /compress: append the same warning to the manual compress reply so users running /compress see the failure too. Acceptance: - Summary success: no user-visible warning (unchanged). - Summary failure on gateway hygiene: user receives a TG/Discord message with dropped count + error + remediation hint. - Summary failure on /compress: warning appended to the command reply. - CLI status_callback / _emit_warning path is untouched. - Test coverage: two new tests verify the tracking fields are set on failure and cleared on subsequent success.
Collaborator
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
…ning The fallback placeholder said "N conversation turns were removed" while the gateway warning said "N historical message(s) were removed". Use "messages" in both so users don't wonder if the two counters refer to different things.
The per-call reset block at the top of compress() cleared _last_summary_dropped_count and _last_summary_fallback_used but not _last_summary_error. Functionally this didn't break the gateway warning path (callers gate on _last_summary_fallback_used first, and _last_summary_error is overwritten on the next failure), but it left the three tracking fields inconsistent — anyone reading _last_summary_error standalone after a successful compress would see a stale value from a previous failed compress. Reset all three together so the per-call contract is uniform.
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
teknium1
pushed a commit
that referenced
this pull request
Apr 28, 2026
…ing delivery Address review feedback on PR #16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
teknium1
pushed a commit
that referenced
this pull request
Apr 28, 2026
PR #16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
Contributor
|
Your 5 commits were cherry-picked onto current main and rebase-merged, so your authorship is preserved in |
Contributor
|
That's fast merging, @teknium1 , let's go let's go! |
cluricaun28
referenced
this pull request
in cluricaun28/Logos
Apr 28, 2026
…ing delivery
Address review feedback on PR #16333:
1. The hygiene-path warning send was missing metadata=_hyg_meta. On
Telegram topics / Slack threads / Discord threads the warning would
land in the main channel instead of the originating thread. Now
reuses the same _hyg_meta dict already computed for the hygiene
compaction itself.
2. New gateway-level test
test_session_hygiene_warns_user_when_summary_generation_fails
verifies end-to-end:
- When the compressor's _last_summary_fallback_used flag is True,
the gateway invokes adapter.send() exactly once.
- The warning message includes the dropped count and the underlying
error string.
- metadata={'thread_id': ...} is propagated so the warning lands
in the originating topic/thread.
Tests: 20 gateway hygiene + 54 context_compressor — all pass.
cluricaun28
referenced
this pull request
in cluricaun28/Logos
Apr 28, 2026
PR #16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…ing delivery Address review feedback on PR NousResearch#16333: 1. The hygiene-path warning send was missing metadata=_hyg_meta. On Telegram topics / Slack threads / Discord threads the warning would land in the main channel instead of the originating thread. Now reuses the same _hyg_meta dict already computed for the hygiene compaction itself. 2. New gateway-level test test_session_hygiene_warns_user_when_summary_generation_fails verifies end-to-end: - When the compressor's _last_summary_fallback_used flag is True, the gateway invokes adapter.send() exactly once. - The warning message includes the dropped count and the underlying error string. - metadata={'thread_id': ...} is propagated so the warning lands in the originating topic/thread. Tests: 20 gateway hygiene + 54 context_compressor — all pass.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
PR NousResearch#16333 added a warning to the manual /compress reply when the auxiliary summariser fails and the static fallback placeholder is used, but only the gateway-hygiene path had a test (test_session_hygiene_warns_user_when_summary_generation_fails). The /compress branch in _handle_compress_command was uncovered. New test test_compress_command_appends_warning_when_summary_generation_fails mocks the compressor's _last_summary_fallback_used / _last_summary_dropped_count / _last_summary_error fields and verifies the /compress reply contains the⚠️ marker, the underlying error string, the dropped message count, and the 'historical message(s) were removed' wording — i.e. the same contract the hygiene-path test enforces.
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.
Fixes #16650
Problem
When auxiliary compression's summary LLM call fails (e.g. model 404, misconfigured
auxiliary.compression.model), the compressor still drops the selected turns and inserts a static fallback placeholder. The dropped context is unrecoverable.Previously the only signal of this failure was a
WARNINGinagent.log. Gateway users (Telegram / Discord / Slack / etc.) had no visible signal that context was lost. A user could come back to a session, find earlier work missing, and have no idea why.Why the existing
_emit_warningpath didn't catch itThe gateway hygiene path uses a temporary
_hyg_agentconstructed withquiet_mode=True,_print_fn = no-op, and nostatus_callback. So_emit_warning(which depends onstatus_callback) silently no-ops in this code path. The CLI / normal-agent path was already covered.Reproducible scenario:
auxiliary.compression.modelset to a model the main provider doesn't serve (e.g. a Google model name routed to Anthropic). Every hygiene-triggered compaction logsFailed to generate context summary: ... 404 ..., the placeholder gets inserted, and the user sees nothing in their chat.Fix
agent/context_compressor.py— track per-compress state:_last_summary_fallback_used: bool_last_summary_dropped_count: intCleared at the top of
compress()and onon_session_reset(). Set when summary generation fails and the static fallback is inserted.gateway/run.pyhygiene auto-compress — after_compress_contextreturns, inspect_hyg_agent.context_compressor. If_last_summary_fallback_usedis True, send a visiblegateway/run.py/compressmanual command — append the same warning to the manual/compressreply so users running it explicitly also see the failure.Acceptance
/resetor checkauxiliary.compression)./compress→ warning appended to the command reply.status_callback/_emit_warningpath is untouched (no behavioural regression).tests/agent/test_context_compressor.pyverify tracking fields are set on failure and cleared on subsequent success.Tests
New tests:
TestSummaryFailureTrackingForGatewayWarning::test_compress_records_fallback_and_dropped_count_on_summary_failureTestSummaryFailureTrackingForGatewayWarning::test_compress_clears_fallback_flag_on_subsequent_successNotes
The warning is only sent to the platform that triggered the hygiene compaction (
source.platform/source.chat_id). It does not broadcast to other platforms or sessions. The gateway adapter.sendcall is wrapped in try/except so a warning-delivery failure can't break the compression result.