diff --git a/src/utils/tag-stripping.ts b/src/utils/tag-stripping.ts index f070493a..c59d7135 100644 --- a/src/utils/tag-stripping.ts +++ b/src/utils/tag-stripping.ts @@ -31,7 +31,8 @@ function countTags(content: string): number { const contextCount = (content.match(//g) || []).length; const systemInstructionCount = (content.match(//g) || []).length; const systemInstructionHyphenCount = (content.match(//g) || []).length; - return privateCount + contextCount + systemInstructionCount + systemInstructionHyphenCount; + const persistedOutputCount = (content.match(//g) || []).length; + return privateCount + contextCount + systemInstructionCount + systemInstructionHyphenCount + persistedOutputCount; } /** @@ -55,6 +56,7 @@ function stripTagsInternal(content: string): string { .replace(/[\s\S]*?<\/private>/g, '') .replace(/[\s\S]*?<\/system_instruction>/g, '') .replace(/[\s\S]*?<\/system-instruction>/g, '') + .replace(/[\s\S]*?<\/persisted-output>/g, '') .trim(); } diff --git a/tests/utils/tag-stripping.test.ts b/tests/utils/tag-stripping.test.ts index 2896aed1..a4a973d6 100644 --- a/tests/utils/tag-stripping.test.ts +++ b/tests/utils/tag-stripping.test.ts @@ -49,6 +49,12 @@ describe('Tag Stripping Utilities', () => { const result = stripMemoryTagsFromPrompt(input); expect(result).toBe('public end'); }); + + it('should strip tags', () => { + const input = 'public large output after'; + const result = stripMemoryTagsFromPrompt(input); + expect(result).toBe('public after'); + }); }); describe('multiple tags handling', () => { @@ -230,6 +236,15 @@ finish`; const parsed = JSON.parse(result); expect(parsed.output).toBe('result '); }); + + it('should strip persisted-output tags from JSON', () => { + const jsonContent = JSON.stringify({ + output: 'big output keep' + }); + const result = stripMemoryTagsFromJson(jsonContent); + const parsed = JSON.parse(result); + expect(parsed.output).toBe(' keep'); + }); }); describe('edge cases', () => {