From a43a0b5cffe1d96abbae4c24b8e8d4bc59d8fb98 Mon Sep 17 00:00:00 2001 From: fz Date: Fri, 31 Jul 2026 14:40:11 +0800 Subject: [PATCH] fix(compact): soften English checkpoint rule --- packages/compact/compact-basic/README.i18n.yaml | 4 ++-- packages/compact/compact-basic/README.md | 4 ++-- packages/compact/compact-basic/README.zh.md | 4 ++-- packages/compact/compact-basic/src/summarizer.ts | 4 ++-- packages/compact/compact-basic/tests/compact-basic.spec.ts | 4 ++-- .../compact/compact-basic/tests/compact-loop-repro.spec.ts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/compact/compact-basic/README.i18n.yaml b/packages/compact/compact-basic/README.i18n.yaml index 3a1a9b923b..9c8ca695c7 100644 --- a/packages/compact/compact-basic/README.i18n.yaml +++ b/packages/compact/compact-basic/README.i18n.yaml @@ -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: 28f27c192c8fe13b01a950d5a5814669c79c5afe -README.zh.md: edac643e69a2cd06832ee0dcbf8b19b5d906386a +README.md: b35e5dc110e908047338054337b309a77b7e0f68 +README.zh.md: 9c5f83d987b584d58ffacadce4e469bb6ba81aa2 diff --git a/packages/compact/compact-basic/README.md b/packages/compact/compact-basic/README.md index 28f27c192c..b35e5dc110 100644 --- a/packages/compact/compact-basic/README.md +++ b/packages/compact/compact-basic/README.md @@ -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. 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. +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. 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. @@ -136,7 +136,7 @@ Output EXACTLY the Markdown structure below: keep every section, in order. Use t - [decisions and their rationale, constraints, user preferences, open questions, data needed to continue] Rules: -- Preserve exact file paths, commands, error strings, identifiers, and function signatures. +- Write concise English engineering prose. Preserve exact file paths, commands, error strings, identifiers, numeric values, function signatures, and syntax fragments. - Capture user feedback and explicit instructions faithfully, especially corrections. - Do NOT mention this summarization request or that the context was compacted. - Output only the checkpoint text: do not call any tool or take any other action. diff --git a/packages/compact/compact-basic/README.zh.md b/packages/compact/compact-basic/README.zh.md index edac643e69..9c5f83d987 100644 --- a/packages/compact/compact-basic/README.zh.md +++ b/packages/compact/compact-basic/README.zh.md @@ -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. 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. +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. 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. @@ -136,7 +136,7 @@ Output EXACTLY the Markdown structure below: keep every section, in order. Use t - [decisions and their rationale, constraints, user preferences, open questions, data needed to continue] Rules: -- Preserve exact file paths, commands, error strings, identifiers, and function signatures. +- Write concise English engineering prose. Preserve exact file paths, commands, error strings, identifiers, numeric values, function signatures, and syntax fragments. - Capture user feedback and explicit instructions faithfully, especially corrections. - Do NOT mention this summarization request or that the context was compacted. - Output only the checkpoint text: do not call any tool or take any other action. diff --git a/packages/compact/compact-basic/src/summarizer.ts b/packages/compact/compact-basic/src/summarizer.ts index 5e2318c66d..ba3dad5592 100644 --- a/packages/compact/compact-basic/src/summarizer.ts +++ b/packages/compact/compact-basic/src/summarizer.ts @@ -29,7 +29,7 @@ const SUMMARY_CLOSE_TAG = '' * 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. 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.', + '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.', '', '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.', '', @@ -58,7 +58,7 @@ const COMPACTION_INSTRUCTION = [ '- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]', '', 'Rules:', - '- Preserve exact file paths, commands, error strings, identifiers, and function signatures.', + '- Write concise English engineering prose. Preserve exact file paths, commands, error strings, identifiers, numeric values, function signatures, and syntax fragments.', '- Capture user feedback and explicit instructions faithfully, especially corrections.', '- Do NOT mention this summarization request or that the context was compacted.', '- Output only the checkpoint text: do not call any tool or take any other action.', diff --git a/packages/compact/compact-basic/tests/compact-basic.spec.ts b/packages/compact/compact-basic/tests/compact-basic.spec.ts index 0694365674..264f8ba45f 100644 --- a/packages/compact/compact-basic/tests/compact-basic.spec.ts +++ b/packages/compact/compact-basic/tests/compact-basic.spec.ts @@ -1224,8 +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('Produce only an English-language internal engineering checkpoint') - expect(lastText).toContain('Translate narrative source material as needed; preserve exact literals.') + expect(lastText).toContain('Write concise English engineering prose.') + expect(lastText).toContain('numeric values, function signatures, and syntax fragments.') expect(lastText).toContain('## Primary Request and Intent') }) diff --git a/packages/compact/compact-basic/tests/compact-loop-repro.spec.ts b/packages/compact/compact-basic/tests/compact-loop-repro.spec.ts index 54246c197c..e6f98817c3 100644 --- a/packages/compact/compact-basic/tests/compact-loop-repro.spec.ts +++ b/packages/compact/compact-basic/tests/compact-loop-repro.spec.ts @@ -345,8 +345,8 @@ describe('context-overflow recovery across the real loop and compact-basic', () 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(instruction).toContain('Write concise English engineering prose.') + expect(instruction).toContain('numeric values, function signatures, and syntax fragments.') expect(JSON.stringify(adapter.conversationRequests[0]!.messages)).toContain('OLD HISTORY SENTINEL') const retry = JSON.stringify(adapter.conversationRequests[1]!.messages) expect(retry).toContain('RECOVERY CHECKPOINT')