Skip to content

Add simple compaction capabilities, preliminary - #110

Merged
alexzhang13 merged 2 commits into
mainfrom
compaction
Feb 17, 2026
Merged

alexzhang13 merged 2 commits into
mainfrom
compaction

Conversation

@alexzhang13

Copy link
Copy Markdown
Owner

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.

@alexzhang13
alexzhang13 merged commit b38ad84 into main Feb 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant