feat(core): resilient compaction with reactive retry and middle-out removal#821
Merged
feat(core): resilient compaction with reactive retry and middle-out removal#821
Conversation
…rompt Add ContextLengthExceeded error variant with provider-specific pattern detection. Implement reactive compaction: intercept context overflow, auto-compact, retry up to 2 times. Progressive middle-out tool response removal as fallback when summarization itself exceeds context (10/20/50/ 100% tiers). Replace generic summarization prompt with structured 9-section template (User Intent, Technical Concepts, Files & Code, Errors & Fixes, Problem Solving, User Messages, Pending Tasks, Current Work, Next Step). Add build_metadata_summary as LLM-free final fallback with safe UTF-8 truncation.
Add 19 tests for resilient compaction: call_chat_with_tools_retry (3 scenarios), build_chunk_prompt validation (9 sections), remove_tool_responses_middle_out edge cases, build_metadata_summary robustness, truncate_chars UTF-8 safety, E2E compaction recovery. Update docs/src/advanced/context.md with structured compaction prompt, progressive tool response removal, metadata fallback, reactive retry. Update all READMEs with M30 feature descriptions.
1c04e2b to
48cc482
Compare
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.
Summary
ContextLengthExceedederror variant with heuristic pattern matching across Claude, OpenAI, and Ollama providerscall_llm_with_retry()andcall_chat_with_tools_retry()— intercept context length errors, auto-compact, retry up to 2 attemptsbuild_metadata_summary()LLM-free fallback with safe UTF-8 truncation viatruncate_chars()Closes #792, closes #807, closes #808, closes #809, closes #810
Test plan
cargo +nightly fmt --checkpassescargo clippy --workspace -- -D warningspassescargo nextest run --workspace --lib --bins— 2626 tests pass