Skip to content

fix: skip post-idle compaction when cache warmer kept the cache warm#258

Merged
BYK merged 1 commit into
mainfrom
fix/skip-post-idle-compact-when-cache-warm
May 12, 2026
Merged

fix: skip post-idle compaction when cache warmer kept the cache warm#258
BYK merged 1 commit into
mainfrom
fix/skip-post-idle-compact-when-cache-warm

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 12, 2026

Summary

  • Fix cache bust on idle resume: onIdleResume() unconditionally set postIdleCompact=true, forcing Layer 1+ with a tight raw budget. When the cache warmer (automated or /keep) had recently refreshed the upstream cache, the compacted context produced different bytes than the warmed prefix — busting the cache and wasting the warming cost.
  • Add skipCompact parameter to onIdleResume() (default false, backwards-compatible). The gateway pipeline checks whether the cache was warmed within the current TTL window via a new isCacheWarm() helper and skips compaction when the cache is warm. All other idle-resume housekeeping (cache clearing, cameOutOfIdle, LTM refresh) still runs.
  • Fix vectorSearch test isolation: beforeEach was scoped to one project but vectorSearch() queries globally, causing 3 pre-existing test failures from cross-suite leaks.

Changes

File What
packages/core/src/gradient.ts Add skipCompact param to onIdleResume(), conditional postIdleCompact
packages/gateway/src/pipeline.ts Add isCacheWarm() helper, import resolveWarmingProfile, pass skipCompact at call site
packages/core/test/gradient.test.ts 2 new tests for skipCompact behavior
packages/core/test/embedding.test.ts Fix vectorSearch describe cleanup to be global

Test plan

  • bun test — 1187 pass, 0 fail (was 1184 pass, 3 fail before the embedding fix)
  • bun run typecheck — clean across all 4 packages

onIdleResume() unconditionally set postIdleCompact=true, forcing Layer 1+
with a tight raw budget on resume. When the cache warmer (automated or
/keep) had recently refreshed the upstream cache, this produced different
bytes than what the warmer replayed — busting the cache and wasting the
warming cost.

Add a skipCompact parameter to onIdleResume() (default false). The gateway
pipeline checks whether the cache was warmed within the current TTL window
via a new isCacheWarm() helper and passes the result through. All other
idle-resume housekeeping (cache clearing, cameOutOfIdle, LTM refresh) still
runs — only the compaction is skipped.

Also fix vectorSearch test isolation: beforeEach was scoped to one project
but vectorSearch() queries globally, causing cross-suite leaks.
@BYK BYK merged commit a60ac53 into main May 12, 2026
7 checks passed
@BYK BYK deleted the fix/skip-post-idle-compact-when-cache-warm branch May 12, 2026 15:40
This was referenced May 13, 2026
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