[bug(opencode)] Resuming an opencode session never re-registers on 2.2.1 -> all writes fail
Summary
On engram 2.2.1, any opencode conversation that is resumed (reopened) after its session was ended is permanently unable to write observations/prompts from that opencode process. Every attributed write aborts with:
gentle-engram could not confirm Engram session registration for <tool>
Environment
- engram 2.2.1 (latest release, 2026-09-25)
- opencode (Node) 1.18.33, Windows 11, plugin regenerated via
engram setup opencode
- Write path: plugin -> serve
POST /sessions (ensureSession) then observation write
Repro
- Start opencode on a conversation (id
ses_xxx). Writes work.
- End that session with
POST /sessions/{id}/end (plugin dispose/close hook or mem_session_end).
- Resume the SAME conversation (opencode keeps a stable session id across restarts).
- Ask the agent to save a memory. Write fails.
Root cause
- The opencode host adapter resolves the session's stable id (
data.sessionID) on every attributed write and calls POST /sessions via ensureSession(sessionID, renew=true).
- For an id whose row has
ended_at set, the serve replies 409 {"code":"session_already_ended"} and the session is never re-registered/re-opened. There is no reopen/restart endpoint (checked /restart, /reopen, DELETE /sessions) and engram delete session refuses sessions that have observations.
- Reads still work (MCP path is separate), which makes the failure confusing:
mem_context/doctor fine, all writes blocked.
- Workaround on our side: clear
ended_at directly in SQLite, then POST /sessions returns 201. Confirmed end-to-end.
Suggested fix
When a host re-registers an id that exists with ended_at set, treat it as an intentional reactivation (reopen) instead of returning 409 — or provide an explicit reopen endpoint. This is the same family as the pi --continue bug (#1376/#1387), now also reachable from the opencode host. The claude and codex adapters got a registration confirmation at resume (#1478, #1513); the opencode adapter is the remaining gap (#1485 draft).
Related: #1376, #1387, #1396, #1478, #1485, #1513.
[bug(opencode)] Resuming an opencode session never re-registers on 2.2.1 -> all writes fail
Summary
On engram 2.2.1, any opencode conversation that is resumed (reopened) after its session was ended is permanently unable to write observations/prompts from that opencode process. Every attributed write aborts with:
gentle-engram could not confirm Engram session registration for <tool>Environment
engram setup opencodePOST /sessions(ensureSession) then observation writeRepro
ses_xxx). Writes work.POST /sessions/{id}/end(plugin dispose/close hook ormem_session_end).Root cause
data.sessionID) on every attributed write and callsPOST /sessionsviaensureSession(sessionID, renew=true).ended_atset, the serve replies409 {"code":"session_already_ended"}and the session is never re-registered/re-opened. There is no reopen/restart endpoint (checked/restart,/reopen,DELETE /sessions) andengram delete sessionrefuses sessions that have observations.mem_context/doctorfine, all writes blocked.ended_atdirectly in SQLite, thenPOST /sessionsreturns201. Confirmed end-to-end.Suggested fix
When a host re-registers an id that exists with
ended_atset, treat it as an intentional reactivation (reopen) instead of returning 409 — or provide an explicit reopen endpoint. This is the same family as thepi --continuebug (#1376/#1387), now also reachable from the opencode host. The claude and codex adapters got a registration confirmation at resume (#1478, #1513); the opencode adapter is the remaining gap (#1485 draft).Related: #1376, #1387, #1396, #1478, #1485, #1513.