Repository navigation
Description
Symptom
memory_recall (and injection) silently misses rows that are present and correctly stamped in the daily logfmt, for sessions hosted by the Desktop app / opencode-cli serve (host 2.1.4). Writes from such sessions are stamped with the wrong repo identity, so they are visible only to their own session; rows written in the real repo are invisible to them.
Root cause
Per-session repo identity (src/repokey.ts, src/index.ts) is learned from:
ctx.session.context()message payloads — readingm.location.directory/m.info.location.directory- session events (created / execution.started / moved)
On host 2.1.4 neither source carries the directory:
- The host stores it on the session row (
opencode.db→session_v2.directory); message payloads (session_message.data, all types: user/assistant/system/…) contain nolocationfield. - The event path did not bind either (observed with
eventtable empty; subscription likely never sees a directory-bearing payload).
Binding therefore fails silently and every write falls back to the module scope — the server process cwd. Observed: a session whose session_v2.directory is the project repo wrote rows stamped repo=/Users/Alex/.config/opencode repoPath=/Users/Alex/.config/opencode.
Secondary defect
A session in a non-git directory stamps repo with the raw path, quoted, spaces included: repo="/Users/Alex/Documents/Default Project". This breaks naive field parsing and makes the row unmatchable by hash-based identity forever.
Evidence
~/.local/share/opencode/opencode.db:session_v2.directory= correct project path; message payloads have nolocation.~/.config/opencode/memory/2026-10-24.logfmt: same repo, same day — rows stamped5699fad3a258(bound TUI session) vsrepo=/Users/Alex/.config/opencode(unbound Desktop session); recall in the Desktop session sees only its own.- Repro: Desktop session in this repo →
memory_remember→ inspect the appended row'srepo=; thenmemory_recallfrom a TUI session in the same repo does not see it.
Expected
Session identity resolves from the host's session location (whatever API actually carries it in V2 — session info, not message payloads), and an unbindable session must NOT silently write repo-partitioned rows under a fallback scope — it should stay unscoped (global-visible) or bind lazily and re-stamp.
Notes
- Found while dogfooding 0.8.x; the same code path exists in 0.6.5 and current main (
bindSessionFromMessagesreadslocation?.directory). - Related:
opencode plugin updateonly refreshes the cache snapshot; the running service keeps the old code until the service itself restarts.
Activity
abogartz commentedon Oct 24, 2026
Root cause confirmed with recorded host payloads (opencode 2.1.4, probe plugin capturing the plugin-side view):
Standalone (
opencode run) — works. The plugin loads before the session exists, so it receivessession.created, whose payload carrieslocation.directory:{"type":"session.created","location":{"directory":"<proj>"},"data":{"sessionID":"ses_…","location":{"directory":"<proj>"},…}}The stamped row is byte-correct:
repo=38315f5bf4a6(sha1 of the probe origin)repoPath=<proj toplevel>.Serve (
opencode serve --service, production) — broken. The plugin loads lazily on the first prompt for a location, i.e. AFTERPOST /api/sessioncreated the session →session.createdis never delivered. The only identity event that arrives per turn is:{"type":"session.execution.started","durable":{"aggregateID":"ses_…"},"data":{"sessionID":"ses_…"}}— no
locationanywhere. The message-payload fallback also cannot work:GET /api/session/{id}/contextreturns messages with nolocationfield (all message types checked); the directory lives only on the session row (GET /api/session/{id}→location.directory). All three binding paths miss → writes fall back to the module scope (server cwd) → silent recall partitioning.Why the harness missed it (two structural gaps):
test/repo-scope-session.test.tsfeeds the fake event bus and fakesession.contextthe payload shapes the plugin hopes for (locationon events,locationon messages). The unit fakes encode the same wrong assumption as the production code — fakes must be recorded from the real host, not imagined.e2e/runs onlyopencode run --standalone— the mode where the bug does not exist — and no scenario ever asserts therepo=stamp on the written row.Fix direction: on identity events lacking a directory, resolve it from the session API (
ctx.session.get→location.directory, verified present in serve mode) before any store write; and add a serve-mode e2e scenario that asserts the stamp, plus a unit replay using the recorded real payload shapes (execution.started without location, context messages without location).Merge pull request #91 from abogartz/fix/serve-mode-identity
chore(release): 0.8.12 [skip ci]
abogartz-opencode-self-improvement commentedon Oct 24, 2026
🎉 This issue has been resolved in version 0.8.12 🎉
The release is available on:
Your semantic-release bot 📦🚀
fix(memory): bind serve-host session identity from the session row
test(e2e): give the serve guest a PATH that can find git on Windows (#…