Skip to content

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

Open
kill74/opencode
#4

Description

@FossenWang

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 / generate hook only checks session.parentID,
    not session.time.archived;
  • only session.deleted calls FiberMap.remove for 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

  1. When session.archived arrives, immediately remove the session's warming
    loop.
  2. Do not schedule warming for an archived session, even if it is prompted
    again through opencode run --archived or the API.
  3. Do not start warming on session.unarchived; a later normal request should
    be able to schedule it again.
  4. Keep the existing session.deleted cleanup and plugin-close behavior
    unchanged.

Acceptance criteria

  • Archive a session that has an active warming loop; after one interval, no
    new warming session log or warm request appears for that session.
  • Send a normal request to an archived session (including
    opencode run --archived); no scheduled session warming appears 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

Activity

  1. opencodejr commented on Nov 20, 2026

    @opencodejr
    Contributor

    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 on session.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:

  2. added
    area/plugins
    type/feature
    version/v2
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/pluginstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions