Compaction fixes - #5
Merged
Merged
Conversation
Memory compaction state defaulted its base path to process.cwd(), which
scattered memory.json into whatever directory core was launched from (e.g.
the repo root) and orphaned it from the session it belongs to. Root it at
~/.freecode/memory/{sessionId} like every other ~/.freecode subsystem.
Also make save() atomic (write to a temp file, then rename) so a crash
mid-write can no longer corrupt memory.json — load() treats a corrupt file
as "no memory" and would otherwise silently discard the whole session.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>warningBufferTokens and minPreserveRecentTokens were defined and defaulted in CompactionConfig but never read anywhere. Drop them so the config stops implying behavior that doesn't exist. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…dCompact shouldCompact() now accepts an optional contextLimit so callers can pass the model's real context window (from models.dev); it falls back to the local value only when that lookup returns nothing (offline / unknown model). Collapse the drift-prone per-model MODEL_CONTEXT_LIMITS table into a single FALLBACK_CONTEXT_LIMIT constant: since it's now just an offline floor, being wrong only compacts slightly early, never loses data, so a per-model table would be pure maintenance cost. Tests updated for the fallback + explicit-limit paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add createLlmSummarizer(), which asks the active provider to write a structured handoff summary (Goal / Done / In Progress / Blocked / Decisions / Relevant Files / Next Steps) instead of the old keyword-matching heuristic. Refactor summarizer.ts to extract makeSummary(input, content) so the heuristic and LLM paths share identical token bookkeeping; the heuristic stays as the fallback when no provider is available or the call fails. Also fix the extractWorkStatus classifier so "no errors"/"error handling" no longer count as blockers (word-boundary match + negation guard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MemoryService.shouldCompact() now forwards an optional contextLimit, and compact() accepts CompactOptions.llmSummarize (best-effort LLM summary, heuristic fallback on failure). The agent loop resolves the model's real context window via getModelContextLimit(provider, model) and passes it into shouldCompact, so a 200K/1M model compacts near its actual limit instead of the conservative 100K fallback. It also builds an llmSummarize closure from the active provider/model (cancellable via the loop's AbortController) and passes it to compact() at both call sites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reframe the Memory & Log Compaction node with a plain-English intro (context window as a limited whiteboard), a worked example showing the trigger fires just before the window is full, and a jargon-free 6-step flow. Also sync the diagram with the code: drop the removed config knobs (warningBufferTokens, minPreserveRecentTokens), note the limit comes from models.dev, the summary is LLM-backed with a heuristic fallback, and storage is atomic under ~/.freecode/memory. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
No description provided.