Skip to content

fix(core): stop prompt-cache warming for archived sessions - #65235

Open
neriousy wants to merge 1 commit into
devfrom
warming-skip-archived
Open

neriousy wants to merge 1 commit into
devfrom
warming-skip-archived

Conversation

@neriousy

@neriousy neriousy commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Fixes #65180

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Stops prompt-cache warming when a session is archived and avoids scheduling warming for sessions that are already archived.

  • Subscribes WarmingPlugin (packages/core/src/plugin/warming.ts) to session.archived, clearing outlived and removing the session's warming loop via FiberMap.remove right away.
  • Checks session.time.archived in the context, compaction, and generate hooks before scheduling warming (and removes any existing loop if the session is already archived), so prompting an archived session does not re-arm warming.
  • Leaves session.unarchived unsubscribed so unarchiving does not auto-start warming; a later normal request schedules warming again naturally.
  • Reorders session.deleted cleanup so the warming loop is removed before resolving any pending running deferred.
  • Notes archived session behavior in services/site/src/docs/content/warming.mdx.

How did you verify your code works?

  • Added unit tests in packages/core/test/plugin/warming.test.ts covering archiving a warmed session, archiving while a request is running, prompting an archived session (context, compaction, generate), and unarchiving followed by a normal request.
  • Ran bun run script/test.ts test/plugin/warming.test.ts test/config/warming.test.ts --rerun-each 10 --randomize in packages/core (230/230 passed).
  • Ran bun typecheck and bun run typecheck:tsc in packages/core, bun run check from repo root, and bun run build in services/site.

Screenshots / recordings

N/A (no UI changes).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #58163

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. I ran the plugin's tests on the base and on this branch. On the base, the four new archive tests fail: archived sessions keep warming, or get warming scheduled again when prompted. With this change all 21 tests pass, and typecheck:tsc passes.

Archiving or deleting a session now removes its warming loop straight away. Archiving doesn't clear the session's request-in-progress marker, but that's harmless: the loop waiting on it has already been removed, and the request's end event still clears it.

Public API: unchanged. The plugin only subscribes to the existing session.archived event.

No blocking concerns.

Related: #58163

This branch has not been deployed

No deployments
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.

[FEATURE]: stop warming archived sessions and do not re-arm them

1 participant