Skip to content

fix(cache-warming): Compact on idle when the request snapshot is too large to store - #3921

Merged
BYK merged 3 commits into
mainfrom
fix/idle-compaction-large-snapshot
Nov 21, 2026
Merged

BYK merged 3 commits into
mainfrom
fix/idle-compaction-large-snapshot

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #3913.

Compaction on idle runs at a warmup slot. Before this change, an idle period whose request snapshot was over a limit (snapshot_too_large or images_too_large) got no warm state, so it got no slot and never compacted on idle. Those are the largest prefixes. Compaction on idle needs only the prefix tokens, the model, and the request overhead. It does not need the snapshot.

What changes:

  • At or above the background compaction mark, with idle compaction on, an idle period with an unstored snapshot now keeps its warm state and its first slot. The warm state records why nothing was stored (snapshotSkipReason).
  • At that slot, compactOnIdle runs with canWarm: false, so chooseIdleCompaction chooses only between compact and stop. When the slot does not compact, it skips with the snapshot skip reason, and the idle period stops. No warmup is sent, and no later slot is scheduled. Without a warmup, the cache expires after that slot.
  • These periods still count as unwarmed in the idle period savings. They also record their reply gap now, like any period with warm state. Their return behaviour is the same as other periods in the segment.
  • design/context-compaction.md moves this from Gaps to Rules. The public config reference adds one sentence about it.

via @BYK.

--

View Session [Sentry]

…large to store

An idle period whose request snapshot was over a limit got no warmup slot,
so a large prefix never compacted on idle. Compaction on idle needs no
snapshot. At or above the background compaction mark, such a period now
keeps its first slot. That slot chooses only between compact and stop and
sends no warmup.

Refs #3913

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 21, 2026 12:39pm UTC

Request Review

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 21, 2026 00:29
@sentry-junior
sentry-junior Bot requested a review from BYK November 21, 2026 00:30
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 21, 2026
@BYK
BYK enabled auto-merge (squash) November 21, 2026 08:12
sentry-junior Bot and others added 2 commits November 21, 2026 08:42
…arge-snapshot

Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	design/context-compaction.md
#	packages/junior/src/chat/cache-warming/warmup.ts
The merge of main put warmup.ts over the 1,000-line limit. The recorder of
one agent run is its own boundary: it sees the run's model requests and
hands finished calls to the idle period that warmup.ts owns.

Co-Authored-By: BYK <[email protected]>
@blacksmith-sh

blacksmith-sh Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Found 4 test failures on Blacksmith runners:

Failures

Test View Logs
[inbox] › packages/junior-dashboard/e2e/
composer-typeahead.spec.ts:193:1 › a pasted Slack mention becomes a mention
View Logs
[inbox] › packages/junior-dashboard/e2e/inbox/
composer-questions.spec.ts:306:3 › new UI › a question that docks while the reader read
s back does not move the transcript @new
View Logs
[inbox] › packages/junior-dashboard/e2e/inbox/
conversation-review-items.spec.ts:127:3 › new UI › Send sends docked picks and asks bef
ore a message drops others @new
View Logs
packages/junior-dashboard/e2e/composer-typeahead.spec.ts/
a pasted Slack mention becomes a mention
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@BYK
BYK merged commit f986584 into main Nov 21, 2026
100 of 105 checks passed
@BYK
BYK deleted the fix/idle-compaction-large-snapshot branch November 21, 2026 12:57

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 320754ad Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compact on idle when the request snapshot is too large to store

1 participant