Skip to content

Commit 677a164

Browse files
committed
Fix system-reminder content leaking into persisted UI messages
Moved statsPart lookup to after the gradient transform so the PATCH to OpenCode's server uses the cleaned part text (system-reminder wrappers stripped) rather than the pre-transform ephemeral version.
1 parent c097068 commit 677a164

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-lore",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"license": "MIT",
66
"description": "Three-tier memory architecture for OpenCode — distillation, not summarization",

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ export const LorePlugin: Plugin = async (ctx) => {
224224

225225
const sessionID = output.messages[0]?.info.sessionID;
226226

227-
const lastUserMsg = [...output.messages].reverse().find((m) => m.info.role === "user");
228-
const statsPart = lastUserMsg?.parts.find((p) => p.type === "text");
229-
230227
const result = transform({
231228
messages: output.messages,
232229
projectPath,
@@ -252,6 +249,12 @@ export const LorePlugin: Plugin = async (ctx) => {
252249
backgroundDistill(sessionID);
253250
}
254251

252+
// Look up statsPart AFTER the transform so the PATCHed text is clean
253+
// (system-reminder wrappers stripped). Looking up before would persist
254+
// ephemeral system-reminder content, making it visible in the UI.
255+
const lastUserMsg = [...output.messages].reverse().find((m) => m.info.role === "user");
256+
const statsPart = lastUserMsg?.parts.find((p) => p.type === "text");
257+
255258
if (sessionID && statsPart && lastUserMsg) {
256259
const loreMeta = {
257260
layer: result.layer,

0 commit comments

Comments
 (0)