GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): keep one warming loop per session and ignore compaction by rekram1-node · Pull Request #61724 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 4, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

Since warming became per model (#60025, #60969):

switch to a model without warming → entry deleted, loop keeps sleeping
switch back                       → second loop; both send keep-alives
switch 1h-cache → 5m-cache model  → loop sleeps out the old interval
compaction                        → settings read for the compaction model

The last one can start warming on a session whose model opted out, or stop it when the compaction model doesn't warm.

Change

  • Loops live in a FiberMap keyed by session. Each turn restarts the session's loop, so there's only ever one, and it times from the current settings.
  • The compaction hook is gone.

Verification

  • New test/plugin/warming.test.ts (3 tests, TestClock): all fail on dev, pass here
  • bun test test/plugin in packages/core: 566 pass
  • bun run typecheck in packages/core: no errors

Added by the opencode bot (AI-generated).

Related: #58163

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): keep one warming loop per session and ignore compaction
33578b0
@github-actions github-actions Bot added the contributor label Nov 4, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix looks right. Each new test fails on dev and passes here: one loop per session, timed from the model the session last used, and no compaction hook. bun test test/plugin (566 pass) and tsc -b in packages/core are clean. I didn't run it in the TUI because the simulated model has no cache TTL to warm.

Public API: unchanged. The internal warming plugin just stops registering its compaction hook; config keys and the plugin API are the same.

Two things, both inline: the keep-alive now reaches FiberMap.run from inside the loop's own fiber, which is fragile, and the compaction test only checks that a hook isn't registered.

Related: #58163

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/plugin/warming.ts
interval: settings.interval,
expires,
})
yield* FiberMap.run(

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The keep-alive itself goes through ctx.session.generate, which runs this generate hook inside the loop's own fiber. Today the keep-alive-prompt check above returns before we get here. If that check ever misses (another hook rewrites the last message, the prompt gets wrapped, etc.), FiberMap.run would interrupt the calling fiber, which is the loop itself. Every keep-alive would then be cancelled before it's sent, so warming would quietly stop working. Before this change, a miss only pushed the expiry out. A guard that doesn't depend on matching the prompt would make this robust, e.g. skipping the restart when the current fiber is the session's loop, or setting a flag around the keep-alive generate call.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/plugin/warming.test.ts Outdated
it.effect("ignores compaction, which runs on the compaction model", () =>
Effect.gen(function* () {
const { warmed, turn, hooks } = yield* start
expect(hooks.has("compaction")).toBe(false)

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This test only checks that a compaction hook isn't registered. The rest of it (an uncached turn followed by 10 minutes with no keep-alive) passes on dev too. It checks an implementation detail rather than the behaviour, so I'd drop it and keep the two loop tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): tag in-flight keep-alives instead of matching their prompt
8dbff1b
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Both earlier points are addressed: keep-alives are marked in progress so the loop can't restart itself, and the compaction test that only checked hook registration is now a behaviour test. Tests and tsc -b in packages/core still pass (566 in test/plugin). The public API is unchanged.

One new point on the test mock (inline): the first test no longer fails on dev, so it stopped guarding the duplicate-loop bug.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/plugin/warming.test.ts
// Like the real one, a keep-alive runs the generate hook before it is sent, and takes a while, so overlapping
// loops would each send one.
generate: () =>
turn("short").pipe(

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Calling turn("short") from the mocked generate makes the first test ("keeps one loop per session…") pass on dev too. With messages: [], dev's prompt check never matches, so each keep-alive resets last for the session. The second loop then wakes, sees it's early, and goes back to sleep, which hides the duplicate keep-alive. Real keep-alives on dev do match the prompt, so this isn't what users see. Keeping the hook re-entry only in the new third test, or passing the keep-alive prompt as the last message here, would let the first test catch the bug again.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Nov 4, 2026
Session warming misses the cache it is meant to keep, and warms providers that don't need it #61775
Open
fix(core): keep the step's own prompt cache warm #61786
Open
A full cache miss request is on the first warming turn instead of continuing with the context's cache #62401
Closed
@FossenWang FossenWang mentioned this pull request Nov 20, 2026
feat(core): stop warming archived sessions #65187
Closed
3 of 6 tasks

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

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.