mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-22 11:55:46 +00:00
fix(compaction): clarify serialized tail context
This commit is contained in:
@@ -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"),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user