fix: preserve context when summary generation fails#31242
fix: preserve context when summary generation fails#31242Hinotoi-agent wants to merge 3 commits into
Conversation
|
Likely duplicate of #26189 — both add a deterministic handoff fallback builder for |
|
Thanks for calling out the overlap. I updated this PR to make the relationship with #26189 explicit and to fold in the missing coverage from that branch rather than leaving two near-identical fallback implementations. What changed here:
My intended resolution is that this branch is the focused current-base version of the deterministic fallback handoff and can supersede #26189, rather than landing both independently. #26051 and #5457 remain related but broader/different in scope: this PR only changes the lossy summary-failure fallback path when compaction still proceeds. |
|
Merged via #34310 (commit 042c1d6 on main). Your 3 commits were cherry-picked onto current main with authorship preserved in git log. Thanks for the careful fallback design — extracting user asks, tool calls, file paths, error snippets, and bounded dropped-turn excerpts with redaction and size caps is exactly the right shape for a deterministic handoff when the LLM summarizer is unavailable. |
Summary
This PR hardens the context-compaction fallback that runs when Hermes cannot generate an LLM-written handoff summary.
Issues covered
Before this PR
After this PR
Why this matters
Hermes can hit context pressure at exactly the moment summary generation is unavailable. In that state, the safest behavior is not just to acknowledge that context was removed; it should preserve the useful facts that are still locally available. This keeps long-running coding and operations sessions recoverable without depending on a second successful LLM call.
Affected code
agent/context_compressor.pytests/agent/test_context_compressor.pyRoot cause
The old fallback path treated summary failure as an all-or-nothing case:
That meant Hermes already had the compacted turns locally, but did not mine them for safe, low-cost continuity signals before dropping them.
Changes in this PR
_build_static_fallback_summary()to construct a deterministic fallback summary from compacted turns.Files changed
agent/context_compressor.pytests/agent/test_context_compressor.pyRelated PRs / duplicate note
abort_on_summary_failureis false and Hermes is already dropping a middle window.If maintainers prefer one canonical branch, this PR is intended as the focused current-base version of the deterministic fallback handoff and can supersede #26189, rather than landing both independently.
Maintainer impact
Fix rationale
Type of change
Test plan
Executed with:
python -m pytest tests/agent/test_context_compressor.py -q -o 'addopts='python -m py_compile agent/context_compressor.py tests/agent/test_context_compressor.pygit diff --checkNotes