fix(compression): preserve context when summary fails#25588
Open
franksong2702 wants to merge 2 commits into
Open
fix(compression): preserve context when summary fails#25588franksong2702 wants to merge 2 commits into
franksong2702 wants to merge 2 commits into
Conversation
Author
|
Follow-up pushed after the duplicate note on #25585:
|
15 tasks
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.
What does this PR do?
Prevents automatic context compression from discarding conversation turns when summary generation fails.
Previously, if the summary LLM/provider failed,
ContextCompressor.compress()inserted a static "summary unavailable" marker and still dropped the middle turns. That is risky for long-running sessions because the visible transcript can remain available while the model-facing context loses recent work and keeps an old protected head.This changes failed-summary compression to fail closed: record warning state for callers, but return the original messages unchanged.
Related Issue
Fixes #25585
Type of Change
Changes Made
agent/context_compressor.py_generate_summary()returns no summary._last_summary_fallback_used,_last_summary_dropped_count, and_last_summary_erroravailable so callers can surface warnings.compression_countfor failed compression.tests/agent/test_context_compressor.pycall_llmwhere tests expect compression.tests/agent/test_context_compressor_summary_continuity.pyHow to Test
scripts/run_tests.sh tests/agent/test_context_compressor.py tests/agent/test_context_compressor_summary_continuity.py tests/agent/test_compress_focus.py tests/gateway/test_compress_command.py tests/gateway/test_compress_focus.py tests/run_agent/test_compressor_fallback_update.py tests/run_agent/test_compression_persistence.pypython3 - <<'PY'\nimport py_compile\npy_compile.compile('agent/context_compressor.py', doraise=True)\nprint('py_compile ok')\nPYgit diff --checkChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Focused test run:
git diff --checkcompleted with no output.