Bug
In the opencode capture plugin (plugins/opencode/agentmemory-capture.ts), projectPath is resolved as:
projectPath = ctx.worktree || ctx.project?.id || process.cwd();
When ctx.worktree is null (which happens for Subagent sessions, e.g. @explore, @code-reviewer, @test-runner), the fallback is ctx.project?.id — a hash like 0f93c5906cef66e3257256da13750ddc9fee4e84 — instead of the actual filesystem path.
Impact
Sessions from subagents (and any session where ctx.worktree is not set) get stored in agentmemory under the wrong project identifier. They are invisible to agentmemory_memory_profile and filtered out when querying by project path. In our stock_brawl2 project, 388 out of 983 sessions (39%) were affected.
Fix
Add ctx.project?.worktree as an intermediate fallback:
projectPath = ctx.worktree || ctx.project?.worktree || ctx.project?.id || process.cwd();
ctx.project?.worktree contains the canonical filesystem path (from the OpenCode project table's worktree column) and is set even when the per-session ctx.worktree is null. The hash ID remains as the final fallback.
Plugin file location
plugins/opencode/agentmemory-capture.ts, line 209 (or similar — the file may be at ~/.config/opencode/plugins/agentmemory-capture.ts in local installations).
Bug
In the opencode capture plugin (
plugins/opencode/agentmemory-capture.ts),projectPathis resolved as:When
ctx.worktreeisnull(which happens for Subagent sessions, e.g. @explore, @code-reviewer, @test-runner), the fallback isctx.project?.id— a hash like0f93c5906cef66e3257256da13750ddc9fee4e84— instead of the actual filesystem path.Impact
Sessions from subagents (and any session where
ctx.worktreeis not set) get stored in agentmemory under the wrong project identifier. They are invisible toagentmemory_memory_profileand filtered out when querying by project path. In our stock_brawl2 project, 388 out of 983 sessions (39%) were affected.Fix
Add
ctx.project?.worktreeas an intermediate fallback:ctx.project?.worktreecontains the canonical filesystem path (from the OpenCode project table'sworktreecolumn) and is set even when the per-sessionctx.worktreeis null. The hash ID remains as the final fallback.Plugin file location
plugins/opencode/agentmemory-capture.ts, line 209 (or similar — the file may be at~/.config/opencode/plugins/agentmemory-capture.tsin local installations).