Repository navigation
Description
Summary
Archiving a session should stop its prompt-cache warming. Today, archiving a
finished session hides it from session lists but leaves its warming loop alive,
so the server keeps sending keep-alive requests until duration expires. This
is surprising for users who archive sessions specifically to stop spending on
them, and it can continue for hours after the session is effectively done.
Current behavior
Warming is a built-in plugin with one in-memory loop per top-level session
(packages/core/src/plugin/warming.ts). Its lifecycle handling only reacts to
session.deleted:
- the event subscription does not include
session.archived; - the
context/compaction/generatehook only checkssession.parentID,
notsession.time.archived; - only
session.deletedcallsFiberMap.removefor the session.
Session.archive itself only publishes session.archived and writes
time.archived; it does not interrupt the session or remove its warming loop
(packages/core/src/session/session.ts). As a result, an archived session keeps
warming until the original window ends, a cache miss occurs, the session is
deleted, or the server/plugin restarts.
A companion plugin cannot fix this cleanly: it can subscribe to
session.archived, but the warming FiberMap is private to the built-in
plugin, and there is no public "cancel warming for this session" API.
Expected behavior
- When
session.archivedarrives, immediately remove the session's warming
loop. - Do not schedule warming for an archived session, even if it is prompted
again throughopencode run --archivedor the API. - Do not start warming on
session.unarchived; a later normal request should
be able to schedule it again. - Keep the existing
session.deletedcleanup and plugin-close behavior
unchanged.
Acceptance criteria
- Archive a session that has an active warming loop; after one
interval, no
newwarming sessionlog or warm request appears for that session. - Send a normal request to an archived session (including
opencode run --archived); noscheduled session warmingappears for it. - Unarchive the session and send a normal request; warming schedules again.
- Deleting a session still stops warming immediately.
- Closing the plugin still stops all warming loops.
- Existing warming tests pass, with new coverage for the archived cases.
Alternatives considered
- Manual per-session on/off ([FEATURE]: Warming per Session #58163). Useful, but it does not make archive
a lifecycle boundary; users would still have to remember to turn warming off
before archiving. - Only warm sessions currently open in a client (core: session warming should target sessions currently open in the client #41003). Adjacent idea,
but it was closed as not planned and does not match the archive semantics. - Replace the built-in warming plugin. Possible, but requires copying
configuration/catalog resolution and about 200 lines of loop logic; a small
change in the built-in plugin is much easier to maintain. - Do nothing and wait for
duration. This is the current behavior and the
reason for this request; it keeps paying for pings after the user has
explicitly archived the session.
Additional context
- refactor(core): give each warmed session one owned loop #62972 (merged) already gives each warmed session one owned loop, so the
implementation is small: addsession.archivedto the event list, remove the
loop for archived sessions, and checksession.time.archivedin the hook. - feat: idle session compaction before prompt-cache expiry #64039 (withdrawn) used "archived sessions are ignored" in its presence-lease
design, which suggests archive is already treated as a lifecycle signal in
adjacent features. - I can prepare a PR with the source change and tests if this behavior is
acceptable.
Activity
opencodejr commentedon Nov 20, 2026
Thanks for the detailed write-up! You're asking for archiving to stop a session's prompt-cache warming right away, and for warming not to be scheduled again while the session stays archived. Unarchiving should not restart it until the next normal request.
Your reading of the code matches what I found. In
packages/core/src/plugin/warming.ts, the event handler removes a session's loop only onsession.deleted. The warming docs describe warming as continuing until 30 minutes after the latest non-warming request, and they don't mention archiving. So I've filed this as a feature request rather than a bug. Maintainers will consider it, along with your offer of a PR.Related issues: