Skip to content

Commit 3a8c120

Browse files
committed
feat(session): add automatic retention cleanup for archived sessions
Add configurable session retention that auto-deletes archived sessions older than retention.days (default: 30, 0 = disabled). Runs every 6 hours via Scheduler, batched at 100 sessions per run. Also call FileTime.remove() on session archive and delete to clean up per-session read timestamps. The database had grown to 1.99GB with 1,706 sessions spanning 53 days because there was no automatic cleanup — sessions were only soft-archived but never deleted.
1 parent 2336d46 commit 3a8c120

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/opencode/src/config/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,16 @@ export namespace Config {
11941194
url: z.string().optional().describe("Enterprise URL"),
11951195
})
11961196
.optional(),
1197+
retention: z
1198+
.object({
1199+
days: z
1200+
.number()
1201+
.int()
1202+
.min(0)
1203+
.optional()
1204+
.describe("Auto-delete archived sessions older than this many days (default: 90, 0 = disabled)"),
1205+
})
1206+
.optional(),
11971207
compaction: z
11981208
.object({
11991209
auto: z.boolean().optional().describe("Enable automatic compaction when context is full (default: true)"),

0 commit comments

Comments
 (0)