Symptom
I wanted to find which OpenCode session I worked on a feature in.
codemem remembered the work — memory_get(305) returned the full context. But it only returned session_id: 75, a codemem-internal integer. There was no way to get the actual OpenCode session ID (ses_...) to pull up the transcript.
The mapping does exist in the database. A direct SQLite query against the opencode_sessions junction table resolves it immediately:
SELECT opencode_session_id FROM opencode_sessions WHERE session_id = 75;
-- → ses_251f3820dffedRNBbWdN4ITbUN
But none of the MCP tools perform this JOIN — the data is captured but invisible to consumers.
The gap
Proposed solution
- Add
opencode_session_id as a first-class column on memory_items:
opencode_session_id: text("opencode_session_id"),
- Propagate it during observer extraction in
ingest-pipeline.ts:
const memoryId = store.remember(sessionId, kind, ..., {
opencode_session_id: sessionContext.opencodeSessionId,
...
});
- Include it in
MemoryItemResponse and all MCP tool responses so memory_get, memory_search, etc. return it directly.
This enables tracing any memory back to its source session transcript without manual SQLite queries.
Symptom
I wanted to find which OpenCode session I worked on a feature in.
codemem remembered the work —
memory_get(305)returned the full context. But it only returnedsession_id: 75, a codemem-internal integer. There was no way to get the actual OpenCode session ID (ses_...) to pull up the transcript.The mapping does exist in the database. A direct SQLite query against the
opencode_sessionsjunction table resolves it immediately:But none of the MCP tools perform this JOIN — the data is captured but invisible to consumers.
The gap
opencode_session_id?raw_eventstableopencode_sessionsjunction tablesession_idmemory_itemstable (31 columns)metadata_jsonon memoriesstore.get()/store.search()memory_get,memory_search,memory_pack)session_idonlyProposed solution
opencode_session_idas a first-class column onmemory_items:ingest-pipeline.ts:MemoryItemResponseand all MCP tool responses somemory_get,memory_search, etc. return it directly.This enables tracing any memory back to its source session transcript without manual SQLite queries.