Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: keep long-padded leftover stop tokens held
Dash0825c44ddac3
diff --git a/packages/maker-shared/src/internalCitation.test.ts b/packages/maker-shared/src/internalCitation.test.tsindex 1aac83d032..12b2ecd762 100644--- a/packages/maker-shared/src/internalCitation.test.ts+++ b/packages/maker-shared/src/internalCitation.test.ts@@ -59,6 +59,7 @@ describe('leaked model stop tokens', () => {expect(isPossibleStandaloneStopPrefix(' <|eo')).toBe(true);expect(isPossibleStandaloneStopPrefix('<')).toBe(true);expect(isPossibleStandaloneStopPrefix('<|')).toBe(true);+ expect(isPossibleStandaloneStopPrefix(`${' '.repeat(23)}<|eos|>`)).toBe(true);expect(isPossibleStandaloneStopPrefix('The token is <|eo')).toBe(false);});@@ -79,6 +80,13 @@ describe('leaked model stop tokens', () => {expect(b).toEqual({ pending: '', emitted: true });});+ it('holds a long-padded leftover token until the closer arrives', () => {+ const buffer = { pending: '', emitted: false };+ const padded = `${' '.repeat(23)}<|eos|>`;+ expect(holdStandaloneStopTokenDelta(buffer, padded)).toBeNull();+ expect(buffer).toEqual({ pending: padded, emitted: false });+ });+it('holds a one-character leftover prefix until the closer arrives', () => {const buffer = { pending: '', emitted: false };expect(holdStandaloneStopTokenDelta(buffer, '<')).toBeNull();diff --git a/packages/maker-shared/src/internalCitation.ts b/packages/maker-shared/src/internalCitation.tsindex 268bc3d1c5..765524a6b2 100644--- a/packages/maker-shared/src/internalCitation.ts+++ b/packages/maker-shared/src/internalCitation.ts@@ -92,9 +92,10 @@ export function stripStandaloneModelStopToken(text: string): string {* can be dropped or flushed.*/export function isPossibleStandaloneStopPrefix(text: string): boolean {- if (text.length > MAX_STANDALONE_STOP_PREFIX) return false;const candidate = text.trim();- if (candidate.length === 0) return true;+ if (candidate.length === 0) return text.length <= MAX_STANDALONE_STOP_PREFIX;+ if (MODEL_STOP_TOKENS.has(candidate)) return true;+ if (text.length > MAX_STANDALONE_STOP_PREFIX) return false;return [...MODEL_STOP_TOKENS].some((token) => token.startsWith(candidate));}