Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
13 changes: 13 additions & 0 deletions tests/compaction-agent-preservation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down