Conversation
…tracking, and meta-distill gating - Change idleResumeMinutes default from 60 to 5 to match Anthropic's default-tier cache TTL (5m). Prevents paying cache-write cost to preserve byte-identity of an already-cold cache after short pauses. - Generalize sticky-layer guard to pin at sessState.lastLayer instead of hardcoded 1. Prevents 2→1→2 and 3→2→3 layer oscillation that causes repeated cache busts from structural message changes. - Add bustCount/transformCount to SessionState with log.warn() when bust rate exceeds 50% after 20+ transforms, providing runtime visibility into cache-stability effectiveness. - Add skipMeta option to distillation.run() and gate meta-distillation on cache warmth (timeSinceLastTurn < cacheTTL). Prevents prefix cache invalidation from row ID rewrites when the user returns within the cache TTL window. Forced calls (compaction, overflow) always allow meta-distillation.
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
Four targeted fixes to reduce prompt cache-bust frequency and cost, building on top of the distillation consumption freeze (PR #123):
idleResumeMinutes60→5: Match Anthropic's default-tier 5m cache TTL. After 5m idle, the cache is cold — preserving byte-identity just pays write cost for no benefit. Extended-tier users can set 60 in.lore.json.sessState.lastLayerinstead of hardcoded1. Prevents 2→1→2 and 3→2→3 oscillation that causes repeated structural cache busts.bustCount/transformCountin SessionState withlog.warn()when rate >50% after 20+ transforms. Runtime visibility into cache stability.skipMetaoption ondistillation.run(). When the prompt cache is likely warm (timeSinceLastTurn < cacheTTL), defer meta-distillation to avoid row ID rewrites that bust the prefix cache. Forced calls (compaction, overflow) always allow it.Cost impact
Files changed
packages/core/src/config.ts— idle threshold defaultpackages/core/src/gradient.ts— sticky guard, bust tracking,getLastTurnAt()packages/core/src/distillation.ts—skipMetaoptionpackages/core/src/index.ts— barrel exportpackages/gateway/src/idle.ts— cache-warm gatingpackages/opencode/src/index.ts— cache-warm gatingpackages/opencode/test/index.test.ts— adjust test for new 5m default744 tests pass, 0 failures.