fix(compact): use English checkpoints

This commit is contained in:
fz
2026-07-31 01:36:20 +08:00
parent a36721fa55
commit ed49f1d985
9 changed files with 74 additions and 6 deletions

View File

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/compact/compact-basic/README.md
README.md: 775355f1ac1a7c79c16f66a5b2489d73df7b960d
README.zh.md: bfa139596b5ef61c23d29575bdea5534fa82b158
README.md: 28f27c192c8fe13b01a950d5a5814669c79c5afe
README.zh.md: edac643e69a2cd06832ee0dcbf8b19b5d906386a

View File

@@ -107,7 +107,7 @@ The summarization model receives the conversation replayed verbatim — the same
##### Compaction instruction (final user message)
```markdown
You are now acting as a compaction engine for this AI coding assistant. Condense the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context.
You are now acting as a compaction engine for this AI coding assistant. Produce only an English-language internal engineering checkpoint that condenses the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context. Translate narrative source material as needed; preserve exact literals.
Output EXACTLY the Markdown structure below: keep every section, in order. Use terse bullets, not prose paragraphs. Write "(none)" for an empty section — never drop a section.

View File

@@ -107,7 +107,7 @@ This is an automatically generated checkpoint condensing an earlier span of the
##### 压缩指令(最终 user 消息)
```markdown
You are now acting as a compaction engine for this AI coding assistant. Condense the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context.
You are now acting as a compaction engine for this AI coding assistant. Produce only an English-language internal engineering checkpoint that condenses the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context. Translate narrative source material as needed; preserve exact literals.
Output EXACTLY the Markdown structure below: keep every section, in order. Use terse bullets, not prose paragraphs. Write "(none)" for an empty section — never drop a section.

View File

@@ -29,7 +29,7 @@ const SUMMARY_CLOSE_TAG = '</compacted-summary>'
* request, so the provider's KV cache is reused instead of invalidated.
*/
const COMPACTION_INSTRUCTION = [
'You are now acting as a compaction engine for this AI coding assistant. Condense the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context.',
'You are now acting as a compaction engine for this AI coding assistant. Produce only an English-language internal engineering checkpoint that condenses the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context. Translate narrative source material as needed; preserve exact literals.',
'',
'Output EXACTLY the Markdown structure below: keep every section, in order. Use terse bullets, not prose paragraphs. Write "(none)" for an empty section — never drop a section.',
'',

View File

@@ -1224,7 +1224,8 @@ describe('default one-shot summarizer', () => {
expect(messages[0]).toEqual(prefix)
const last = messages.at(-1)?.content[0]
const lastText = last?.type === 'text' ? last.text : ''
expect(lastText).toContain('Condense the conversation ABOVE')
expect(lastText).toContain('Produce only an English-language internal engineering checkpoint')
expect(lastText).toContain('Translate narrative source material as needed; preserve exact literals.')
expect(lastText).toContain('## Primary Request and Intent')
})

View File

@@ -342,6 +342,11 @@ describe('context-overflow recovery across the real loop and compact-basic', ()
expect(adapter.conversationRequests).toHaveLength(2)
expect(adapter.summaryRequests).toHaveLength(1)
const instruction = adapter.summaryRequests[0]!.messages.at(-1)?.content
.map(block => (block.type === 'text' ? block.text : ''))
.join('') ?? ''
expect(instruction).toContain('Produce only an English-language internal engineering checkpoint')
expect(instruction).toContain('Translate narrative source material as needed; preserve exact literals.')
expect(JSON.stringify(adapter.conversationRequests[0]!.messages)).toContain('OLD HISTORY SENTINEL')
const retry = JSON.stringify(adapter.conversationRequests[1]!.messages)
expect(retry).toContain('RECOVERY CHECKPOINT')