You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Per-session caches (epoch, latestPrompt, sessionStats) grow unbounded in a long-lived server #75
The plugin's per-session caches in src/index.ts grow without bound for the lifetime of the server process. A long-lived opencode serve (or the desktop app's resident server) that hosts many sessions accumulates them forever.
epoch: Map<string, { version; block; at; reason }> — one entry per session ID ever seen; block holds up to injectBudget chars each.
Both are only cleared at compaction (epoch.delete / latestPrompt.delete), so a session that never compacts is never reclaimed.
sessionStats: Map<string, SessionStats> is small but has the same lifetime; measuredTurns likewise.
Pre-existing for epoch; #65 makes it materially worse by adding the largest of the three.
Suggested fix
Mirror what src/repokey.ts already does for this exact shape (SESSION_CAP = 64, evict oldest on insert): a small LRU cap per map, evicting the least-recently-touched session. Semantics are safe — the worst case for an evicted session is one epoch recompute (and the digest line already busts the cache on every write), which is a cost, not a correctness problem.
Acceptance
N sessions (> cap) through one server process: map sizes stay bounded, asserted in a test.
No behavioural change for a single long session; epoch byte-stability across requests is preserved (there is an existing test asserting an unchanged store yields an identical block — keep it green).
Context
Noted while reviewing PR #65 (which adds latestPrompt); split out so the review isn't blocked on a lifetime change.
Follow-up filed: #224. The 2026-10-31 architecture review verified that three ledgers that grow with work remain unbounded after this fix: state.sessions (src/state.ts:102), per-session calls (src/triggers.ts:51), and frontierInjectedSessions (src/inject.ts:228); and src/repokey.ts:93 re-declares SESSION_CAP = 64 instead of importing the shared constant from src/sessions.ts.
Activity
fix(inject): bound per-session state in a long-lived server
abogartz-opencode-self-improvement commentedon Oct 24, 2026
🎉 This issue has been resolved in version 0.8.6 🎉
The release is available on:
Your semantic-release bot 📦🚀
abogartz commentedon Nov 1, 2026
Follow-up filed: #224. The 2026-10-31 architecture review verified that three ledgers that grow with work remain unbounded after this fix:
state.sessions(src/state.ts:102), per-sessioncalls(src/triggers.ts:51), andfrontierInjectedSessions(src/inject.ts:228); andsrc/repokey.ts:93re-declaresSESSION_CAP = 64instead of importing the shared constant fromsrc/sessions.ts.