diff --git a/src/index.ts b/src/index.ts index 5128167..37db063 100644 --- a/src/index.ts +++ b/src/index.ts @@ -973,7 +973,14 @@ export const OpenCodeMemPlugin: Plugin = async (ctx: PluginInput) => { await ctx.client.session.prompt({ path: { id: sessionID }, body: { - parts: [{ id: `prt-compaction-${Date.now()}`, type: "text", text: memoryContext }], + parts: [ + { + id: `prt-compaction-${Date.now()}`, + type: "text", + text: memoryContext, + synthetic: true, + }, + ], noReply: true, agent, }, diff --git a/tests/compaction-agent-preservation.test.ts b/tests/compaction-agent-preservation.test.ts index 614e9c4..54f15be 100644 --- a/tests/compaction-agent-preservation.test.ts +++ b/tests/compaction-agent-preservation.test.ts @@ -200,6 +200,19 @@ describe("session.compacted agent preservation (#236)", () => { expect(result.parsed?.promptCalls[0]?.body?.noReply).toBe(true); }); + it("marks the injected part as synthetic so it is not echoed into the transcript (follow-up to #239)", () => { + const result = runCompactionScenario({ + sessionAgent: "my-orchestrator", + memories: [{ memory: "remember this", tags: ["t1"] }], + messages: [{ info: { role: "user", agent: "my-orchestrator" } }], + }); + + expect(result.exitCode).toBe(0); + expect(result.stderr).toBe(""); + expect(result.parsed?.promptCalls).toHaveLength(1); + expect(result.parsed?.promptCalls[0]?.body?.parts?.[0]?.synthetic).toBe(true); + }); + it("does not call session.prompt when there are no memories", () => { const result = runCompactionScenario({ sessionAgent: "my-orchestrator",