Skip to content

Compaction fixes - #5

Merged
ayan-de merged 6 commits into
mainfrom
compaction-fixes
Jul 23, 2026
Merged

Compaction fixes#5
ayan-de merged 6 commits into
mainfrom
compaction-fixes

Conversation

@ayan-de

Copy link
Copy Markdown
Owner

No description provided.

ayan-deand others added 6 commits July 23, 2026 22:06
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>
@vercel

vercelBot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
freecode-webBuildingBuildingPreviewJul 23, 2026 4:39pm

@ayan-de
ayan-de merged commit b84632f into mainJul 23, 2026
2 checks passed
Sign up for freeto 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

@ayan-de