Skip to content

fix(core): delete blobs a week after they were written - #65671

Merged
rekram1-node merged 2 commits into
devfrom
video-blob-retention
Nov 23, 2026
Merged

rekram1-node merged 2 commits into
devfrom
video-blob-retention

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

None.

Type of change

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

What does this PR do?

Blobs are no longer kept forever. The blob store now deletes each blob a week after it was written, whatever stored it, the same way tool output already cleans up its files. Video job records keep their 24-hour lifetime.

before: video record deleted 24 h after the job finished; its videos in <data>/blobs kept for good
after:  video record deleted 24 h after the job finished (unchanged)
        any blob deleted 7 days after it was written

Nothing ever removed a blob before, and every video the agent tool made is stored twice (blob plus the copy in the project), so <data>/blobs only grew. With video headed for on-by-default that adds up quickly.

The store owns the lifetime rather than the video jobs, so it also catches blobs no job accounts for: a download interrupted mid-write, or a record that couldn't be read. On start and then hourly, BlobStore lists <data>/blobs/blob_* and removes files older than RETENTION (7 days) with the existing FileRetention.cleanup, by modification time.

Trade-off: a client that kept a blob ID gets 404 from GET /api/experimental/blob/:id after a week. Copies the agent tool saved into a project are untouched. The blob route's description says so.

How did you verify your code works?

  • New blob-store.test.ts: a blob whose file is older than a week is gone after the store starts, and a fresh one stays. It fails without the cleanup.
  • video-generation and tool-video-generate tests in core, and video-generate.test.ts in server, pass.
  • bun run check at the root, and tsc in core.

Screenshots / recordings

None.

Checklist

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

Added by the opencode bot (AI-generated).

Public API: blobs served by the experimental blob endpoint are now deleted 7 days after they were written, instead of being kept for good (description of experimental.blob.get updated)

@rekram1-node rekram1-node changed the title fix(core): delete generated videos a week after their job finishes fix(core): delete blobs a week after they were written Nov 23, 2026

@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 works. I ran the updated video-generation.test.ts against the base code and it fails because the job's blobs are still there after 8 days. With this PR it passes. The video-generation and tool-video-generate tests pass with core's test script, and tsc in core is clean. Removing blobs is safe in the cleanup path: blobs.remove ignores errors and a missing file, and only completed jobs have blobs to remove.

Public API: only behaviour and docs on experimental endpoints. GET /api/experimental/generate/video/:id now keeps a finished job for 7 days instead of 24 h, and the experimental.generate.video.get description in the OpenAPI spec says so. Blobs of completed video jobs, read through GET /api/experimental/blob/:id, are now deleted after 7 days instead of being kept for good. A client that keeps a blob ID longer than a week now gets 404. Since these endpoints are marked experimental, that seems acceptable.

One concern, inline: the test now takes ~18s, up from ~4s.

  • packages/core/test/video-generation.test.ts:111: Because this runs inside a live app, TestClock.adjust("8 days") fires every 5-second poll in between, about 138k ticks. The test now takes ~18s locally, up from ~4s on base. That's past Bun's 5s default and about 60% of core's 30s script timeout, so slower CI runners could time out. You can make it fast by advancing the clock while no poller is running. Close the second app, then do yield* TestClock.adjust("8 days"), then check deletion in a fresh app(dir, state). I tried this locally: the file runs in ~2.3s and still passes.

@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.

My earlier point is addressed: the video test is back to its base version and no longer steps through 8 days of polls. The new commits look sound.

I ran blob-store, video-generation and tool-video-generate in core and they pass. With the cleanup call taken out, the new blob-store.test.ts fails, so it checks the fix. tsc in core is clean. The cleanup reuses FileRetention.cleanup and only touches blob_* files. This file blob store is used only for generated videos, and video records expire after 24 h, so they never point at a deleted blob.

Public API: only the experimental.blob.get description changes, from "kept until removed" to "deleted a week after it was stored". GET /api/experimental/blob/:id now returns 404 for blobs older than 7 days. The endpoint is experimental, so this is acceptable. No new concerns.

@rekram1-node
rekram1-node merged commit 8c0be71 into dev Nov 23, 2026
17 checks passed
@rekram1-node
rekram1-node deleted the video-blob-retention branch November 23, 2026 05:25
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
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.

1 participant