fix(core): ensure relevant files survive compaction (#35636)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
co-authored by
Aiden Cline
parent
888dc67cc3
commit
78f85b1cd6
@@ -22,20 +22,27 @@ const SUMMARY_TEMPLATE = `Output exactly the Markdown structure shown inside <te
|
|||||||
- [constraints/preferences, decisions and why, important facts/assumptions, exact context needed to continue, or "(none)"]
|
- [constraints/preferences, decisions and why, important facts/assumptions, exact context needed to continue, or "(none)"]
|
||||||
|
|
||||||
## Work State
|
## Work State
|
||||||
- Completed: [finished work, verified facts, or changes made; otherwise "(none)"]
|
### Completed
|
||||||
- Active: [current work, partial changes, or investigation state; otherwise "(none)"]
|
- [finished work, verified facts, or changes made; otherwise "(none)"]
|
||||||
- Blocked: [blockers, failing commands, or unknowns; otherwise "(none)"]
|
|
||||||
|
### Active
|
||||||
|
- [current work, partial changes, or investigation state; otherwise "(none)"]
|
||||||
|
|
||||||
|
### Blocked
|
||||||
|
- [blockers, failing commands, or unknowns; otherwise "(none)"]
|
||||||
|
|
||||||
## Next Move
|
## Next Move
|
||||||
1. [immediate concrete action, or "(none)"]
|
1. [immediate concrete action, or "(none)"]
|
||||||
2. [next action if known, or "(none)"]
|
2. [next action if known, or "(none)"]
|
||||||
|
|
||||||
|
## Relevant Files
|
||||||
|
- [file or directory path: why it matters, or "(none)"]
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
Rules:
|
Rules:
|
||||||
- Keep every section, even when empty.
|
- Keep every section, even when empty.
|
||||||
- Use terse bullets, not prose paragraphs.
|
- Use terse bullets, not prose paragraphs.
|
||||||
- Preserve exact file paths, symbols, commands, error strings, URLs, and identifiers when known.
|
- Preserve exact file paths, symbols, commands, error strings, URLs, and identifiers when known.
|
||||||
- Put relevant files and symbols inside the section where they matter; do not add extra sections.
|
|
||||||
- Do not mention the summary process or that context was compacted.`
|
- Do not mention the summary process or that context was compacted.`
|
||||||
|
|
||||||
type Entry = {
|
type Entry = {
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { expect, test } from "bun:test"
|
import { expect, test } from "bun:test"
|
||||||
import { SessionCompaction } from "@opencode-ai/core/session/compaction"
|
import { SessionCompaction } from "@opencode-ai/core/session/compaction"
|
||||||
|
|
||||||
|
test("compaction prompt preserves detailed work state and relevant files", () => {
|
||||||
|
const prompt = SessionCompaction.buildPrompt({ context: ["conversation history"] })
|
||||||
|
|
||||||
|
expect(prompt).toContain("## Work State\n### Completed")
|
||||||
|
expect(prompt).toContain("### Active")
|
||||||
|
expect(prompt).toContain("### Blocked")
|
||||||
|
expect(prompt).toContain("## Relevant Files")
|
||||||
|
})
|
||||||
|
|
||||||
test("compaction describes tool media without embedding base64", () => {
|
test("compaction describes tool media without embedding base64", () => {
|
||||||
const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
|
const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
|
||||||
const serialized = SessionCompaction.serializeToolContent([
|
const serialized = SessionCompaction.serializeToolContent([
|
||||||
|
|||||||
Reference in New Issue
Block a user