Repository navigation
Add simple compaction capabilities, preliminary - #110
Merged
Merged
Conversation
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.
Compaction (off by default): Root history is stored in the REPL history variable. When usage reaches a configurable percentage of the model’s context limit, the run is summarized, the summary is appended to history, and the loop continues from that summary. System prompt updated to mention history.
Token-based threshold: Compaction uses a percentage of context (default 85%). Added
rlm.utils.token_utils: model context limits (OpenAI, Anthropic, Gemini, Qwen, Kimi, GLM, gpt-5, gpt-5-nano), containment-based model matching, and token counting (tiktoken when available, else ~4 chars/token).FINAL_VAR: When FINAL_VAR is run inside a REPL block, its value is stored on the execution result and used as the final answer by the main loop (no second execution). Support FINAL_VAR with a direct value (e.g. FINAL_VAR(result) where result is an int). Treat “variable not found” as non-final so the loop can continue; use only stdout for the final answer.
Verbose: Log when compaction runs and, each step, log current tokens vs compaction threshold.