Compare commits

...
Author SHA1 Message Date
Kit Langton ff71b2f85c fix(core): correct compaction history direction 2026-08-27 15:29:59 -04:00
3 changed files with 13 additions and 1 deletions
@@ -0,0 +1,5 @@
---
"@opencode-ai/core": patch
---
Correct the compaction prompt to point existing summaries at the conversation history that follows them.
+1 -1
View File
@@ -215,7 +215,7 @@ const select = (
export const buildPrompt = (input: { readonly previousSummary?: string; readonly context: readonly string[] }) =>
[
input.previousSummary
? `Update the anchored summary below using the conversation history above.\nPreserve still-true details, remove stale details, and merge in the new facts.\n<previous-summary>\n${input.previousSummary}\n</previous-summary>`
? `Update the anchored summary below using the conversation history below.\nPreserve still-true details, remove stale details, and merge in the new facts.\n<previous-summary>\n${input.previousSummary}\n</previous-summary>`
: "Create a new anchored summary from the conversation history.",
SUMMARY_TEMPLATE,
"The following is the conversation history:",
@@ -143,6 +143,13 @@ test("compaction prompt requires the checkpoint headings in order", () => {
expect(prompt).toContain("Keep every section, even when empty.")
})
test("compaction points an existing summary to the following history", () => {
const prompt = SessionCompaction.buildPrompt({ previousSummary: "Previous summary", context: ["Recent history"] })
expect(prompt.split("\n", 1)[0]).toBe("Update the anchored summary below using the conversation history below.")
expect(prompt).not.toContain("conversation history above")
})
it.effect("auto compaction reserves a buffer below the prompt ceiling", () =>
Effect.gen(function* () {
const compaction = yield* SessionCompaction.Service