fix(compaction): clarify serialized tail context

This commit is contained in:
Aiden Cline
2026-05-12 01:30:20 -05:00
parent a6c1941b1f
commit 44062b7976
2 changed files with 10 additions and 4 deletions

View File

@@ -531,7 +531,13 @@ export const layer: Layer.Layer<
type: "text",
metadata: { compaction_tail: true },
synthetic: true,
text: ["<recent-conversation-tail>", tail, "</recent-conversation-tail>"].join("\n\n"),
text: [
"The conversation history before this point was compacted into the summary above.",
"The following messages are the latest conversation turns after that summarized history.",
"<latest-messages>",
tail,
"</latest-messages>",
].join("\n\n"),
})
}

View File

@@ -1123,7 +1123,7 @@ describe("session.compaction.process", () => {
expect(result).toBe("continue")
expect(last?.info.role).toBe("user")
expect(last?.parts.some((part) => part.type === "text" && part.text.includes("recent-conversation-tail"))).toBe(true)
expect(last?.parts.some((part) => part.type === "text" && part.text.includes("latest-messages"))).toBe(true)
expect(all.some((msg) => msg.info.role === "assistant" && msg.info.summary)).toBe(true)
expect(
all.some(
@@ -1400,14 +1400,14 @@ describe("session.compaction.process", () => {
expect(head).not.toContain("and this one too")
expect(prompt).not.toContain("keep this turn")
expect(prompt).not.toContain("and this one too")
expect(prompt).not.toContain("recent-conversation-tail")
expect(prompt).not.toContain("latest-messages")
expect(prompt).not.toContain("What did we do so far?")
const tail = (yield* ssn.messages({ sessionID: session.id })).find(
(item) => item.info.role === "user" && item.parts.some((part) => part.type === "text" && part.synthetic),
)
expect(JSON.stringify(tail?.parts)).toContain("keep this turn")
expect(JSON.stringify(tail?.parts)).toContain("and this one too")
expect(JSON.stringify(tail?.parts)).toContain("recent-conversation-tail")
expect(JSON.stringify(tail?.parts)).toContain("latest-messages")
}).pipe(withCompaction({ llm: stub.layer }))
},
{ git: true },