Skip to content

Commit 78f85b1

Browse files
fix(core): ensure relevant files survive compaction (#35636)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
1 parent 888dc67 commit 78f85b1

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/core/src/session/compaction.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,27 @@ const SUMMARY_TEMPLATE = `Output exactly the Markdown structure shown inside <te
2222
- [constraints/preferences, decisions and why, important facts/assumptions, exact context needed to continue, or "(none)"]
2323
2424
## Work State
25-
- Completed: [finished work, verified facts, or changes made; otherwise "(none)"]
26-
- Active: [current work, partial changes, or investigation state; otherwise "(none)"]
27-
- Blocked: [blockers, failing commands, or unknowns; otherwise "(none)"]
25+
### Completed
26+
- [finished work, verified facts, or changes made; otherwise "(none)"]
27+
28+
### Active
29+
- [current work, partial changes, or investigation state; otherwise "(none)"]
30+
31+
### Blocked
32+
- [blockers, failing commands, or unknowns; otherwise "(none)"]
2833
2934
## Next Move
3035
1. [immediate concrete action, or "(none)"]
3136
2. [next action if known, or "(none)"]
37+
38+
## Relevant Files
39+
- [file or directory path: why it matters, or "(none)"]
3240
</template>
3341
3442
Rules:
3543
- Keep every section, even when empty.
3644
- Use terse bullets, not prose paragraphs.
3745
- Preserve exact file paths, symbols, commands, error strings, URLs, and identifiers when known.
38-
- Put relevant files and symbols inside the section where they matter; do not add extra sections.
3946
- Do not mention the summary process or that context was compacted.`
4047

4148
type Entry = {

packages/core/test/session-compaction.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { expect, test } from "bun:test"
22
import { SessionCompaction } from "@opencode-ai/core/session/compaction"
33

4+
test("compaction prompt preserves detailed work state and relevant files", () => {
5+
const prompt = SessionCompaction.buildPrompt({ context: ["conversation history"] })
6+
7+
expect(prompt).toContain("## Work State\n### Completed")
8+
expect(prompt).toContain("### Active")
9+
expect(prompt).toContain("### Blocked")
10+
expect(prompt).toContain("## Relevant Files")
11+
})
12+
413
test("compaction describes tool media without embedding base64", () => {
514
const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
615
const serialized = SessionCompaction.serializeToolContent([

0 commit comments

Comments
 (0)