feat(devbox): add devbox.onEvict eviction notifications (SSE)#820
Open
jrvb-rl wants to merge 4 commits into
Open
Conversation
❌ Object Smoke Tests FailedTest Results❌ Some smoke tests failed Please fix the failing tests before checking coverage. |
|
✅ Reflex agent status: Completed The agent completed its work. This PR was created by Reflex. This comment updates in place as the agent works. |
Contributor
Author
|
Reconciled with the endpoint as landed:
Ordering: depends on runloopai/runloop#10404, which marks |
Adds an object-oriented `Devbox.onEvict(callback)` backed by a per-client `EvictionMonitor`. The first registration opens a single account-wide `watchEvictions` SSE stream; incoming notifications are matched against the local interest set, the devbox is removed before its callback fires (at-most-once), and the stream is closed once the interest set empties. Depends on the Stainless-generated `devboxes.watchEvictions` method and `DevboxEvictionEvent` type, which land downstream once the server endpoint merges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Use the real generated event type DevboxEvictionEventView (the endpoint's view) in place of the assumed DevboxEvictionEvent. - Invoke the callback as callback(devbox, evictionDeadlineMs): the Devbox object and the Unix millisecond deadline, instead of passing the raw event. Requires the main-repo stainless config change that generates watchEvictions as Stream<DevboxEvictionEventView> (runloopai/runloop#10404). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jrvb-rl
force-pushed
the
feat/devbox-on-evict-sse
branch
from
July 24, 2026 09:34
c5c33b0 to
d8d6f4c
Compare
jrvb-rl
changed the base branch from
main
to
release-please--branches--main--changes--next--components--api-client
July 24, 2026 09:34
jrvb-rl
marked this pull request as ready for review
July 24, 2026 10:04
Hermetic object-coverage test driving the shared EvictionMonitor via an in-memory fake watch_evictions stream: asserts onEvict fires once with (devbox, deadline), unmatched devbox ids are discarded, and cancelOnEvict aborts the stream. Gives the object-coverage suite 100% function coverage of the eviction wrapper without a live eviction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The mux SSE route moved from /v1/devboxes/watch_evictions to
/v1/devboxes/evictions/watch (runloopai/runloop#10409) to avoid colliding
with GET /v1/devboxes/{id}. Update the generated request path so the
watchEvictions method reaches the new endpoint. Method surface unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Follow-on to the server-side flex eviction-notification work (monorepo #10325 and its successor SSE endpoint). Adds the object-oriented client surface for eviction notifications.
New API:
devbox.onEvict(callback)(anddevbox.cancelOnEvict()) on theDevboxwrapper.How it works (internal state management):
EvictionMonitor(src/sdk/eviction.ts) holds the interest set:Map<devbox_id, callback>. Monitors are looked up via aWeakMap<Runloop, EvictionMonitor>(getEvictionMonitor), so everyDevboxbuilt from the same generated client shares one monitor and thus one SSE connection. NoDevbox/factory signatures changed.onEvictacross any devbox opens a single account-widedevboxes.watchEvictions()SSE stream via a backgroundfor awaitloop.AbortControlleris aborted and the stream closed. Re-registering re-opens it.Dependency / status
devboxes.watchEvictionsmethod and theDevboxEvictionEventtype (devbox_id,eviction_deadline_ms), which are generated downstream once the server endpoint lands. Those symbols are imported by assumed name from../resources/devboxes/devboxesand will be reconciled once generation lands. No generated code was modified.Note:
jest.config.objects.jsenforces 100% function coverage oversrc/sdk, so the object-oriented smoke test foronEvict/cancelOnEvict(plus a mockedtests/objectsunit test) is required and will be added when the endpoint is available to exercise.Testing
Deferred until the generated endpoint exists (see above).
🤖 Generated with Claude Code