Repository navigation
bug(opencode): leftover root session from previous day still fail-closes mem_save on 2.0.0-rc.12 #1242
Description
Activity
- addedtype:bugBug fixBug fixstatus:needs-reviewNeeds maintainer reviewNeeds maintainer reviewpriority:highHigh priorityHigh priority
on Sep 17, 2026 Reproduced on Windows with OpenCode 1.18.31 and Engram
2.0.0-rc.12.0.20260917164859-2cdda9041c1b.User-observed runtime state: one OpenCode window open.
Observed behavior:
mem_savewithoutsession_idfailed withmultiple active runtime sessions match the current project and directory.mem_session_summarywithoutsession_idfailed with the same ambiguity.engram doctor --project <project> --check ambiguous_active_runtime_sessions --jsonreported 7 active candidates across 1 directory.- No candidate was selected, ended, or modified.
Comparative evidence: a prior Pi session in the same project successfully wrote both the local continuity backup and the Engram session summary with the same explicit session ID.
Version check: the installed Engram commit is 6 commits behind current
main, butplugin/opencode/engram.tshas the same Git blob at the installed commit and at currentmain, so the current upstream plugin still contains no relevant change for this occurrence.Expected: the current OpenCode root session should be bound unambiguously, or non-live leftover roots should not make omitted-session writes ambiguous.
Actual: both memory writes fail closed despite only one OpenCode window being reported as open.
I traced this issue to an outdated locally installed OpenCode plugin rather than Engram’s core session-selection logic.
After running
engram setup opencode, the installedengram.tswas refreshed. I then verified thatmem_saveandmem_session_summaryboth bound to the correct root OpenCode session, and that a normal OpenCode exit persisted the session’sended_atvalue.The current installed plugin now structurally matches the source on
main(99b7df243fd933ce3c4e1714e8b27c9273e1d755), apart from the expected installer-generatedENGRAM_BINpath.This resolves the reported behavior locally. However, the incident suggests a remaining upgrade/documentation gap: updating the Engram binary does not clearly warn that an installed OpenCode plugin may be stale or that
engram setup opencodeshould be rerun. It may be worth tracking plugin drift detection or documenting the required refresh step separately.Resolved by #1267, merged as
6ad49f17b558004b0fa1f70d161cb9f2fba62aae.The merged owner-liveness contract persists and renews a local runtime lease, prefers a genuinely live leased owner over stale legacy rows in the same directory, and still fails closed when multiple runtimes are actually live. Its regression coverage includes the next-day stale OpenCode root-session scenario reported here, and the final PR head passed the full required CI suite.
Closing as completed. If the same scenario reproduces on a build containing that merge commit, please reopen with the new session rows and
ambiguous_active_runtime_sessionsoutput.
📝 Bug Description
On Engram
2.0.0-rc.12with a single OpenCode session, omitted-sessionmem_savestill fails closed:This was treated as resolved by #1101/#1102 (7-day activity window) and #1131/#1159 (OpenCode sub-agent / misregistered-session close). The remaining case is a leftover root session from the previous day:
ended_atstays NULL, both rows fall inside the 7-day window, and there is no live-process check. One OpenCode window is enough to get two Engram candidates.engram doctor --check ambiguous_active_runtime_sessionsreports the pair. Closing the stale row withmem_session_endunblocks writes. The MCPmem_doctorcall in the same session did not include that check.🔄 Steps to Reproduce
2.0.0-rc.12with OpenCode in a project directory.mem_savewithoutsession_id.engram doctor --project <project-name> --check ambiguous_active_runtime_sessions.✅ Expected Behavior
A leftover root session with no live OpenCode process should not count as a concurrent runtime candidate.
mem_savewithoutsession_idshould resolve to the current session.Fail-closed should apply only when two sessions are genuinely live.
OpenCode root-session end should set
ended_at, not onlysession.deleted, plugin dispose, or archive (#1192).❌ Actual Behavior
Two
ownership_mode=sharedrows for the same project+directory stayedended_at IS NULL:mem_savewithoutsession_idfailed closed until the leftover id was ended. Doctor CLI warned; MCPmem_doctorin that session did not surfaceambiguous_active_runtime_sessions.Operating System
macOS
Engram Version
2.0.0-rc.12
Agent / Client
OpenCode
📋 Relevant Logs
💡 Additional Context
session.deletedor plugin dispose. A normal next-day OpenCode session leaves the previous root open.mem_session_endon the stale id. There is still no CLI that lists active runtime candidates by project+directory besides doctor.