From e141fd7cd536facd3c0fafbb4fcdd388467510e4 Mon Sep 17 00:00:00 2001 From: 7Sageer Date: Wed, 29 Jul 2026 20:56:24 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(kosong):=20match=20Kimi's=20stand?= =?UTF-8?q?alone=20"Unsupported=20image."=20rejection=20(=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dbb69a2678fc9ce3d09e93598c65033378763597. --- .changeset/unsupported-image-standalone-rejection.md | 5 ----- packages/agent-core-v2/src/kosong/contract/errors.ts | 1 - .../agent-core-v2/test/app/llmProtocol/errors.test.ts | 6 ------ packages/kosong/src/errors.ts | 5 ----- packages/kosong/test/errors.test.ts | 9 --------- 5 files changed, 26 deletions(-) delete mode 100644 .changeset/unsupported-image-standalone-rejection.md diff --git a/.changeset/unsupported-image-standalone-rejection.md b/.changeset/unsupported-image-standalone-rejection.md deleted file mode 100644 index 7e1af18d0c..0000000000 --- a/.changeset/unsupported-image-standalone-rejection.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@moonshot-ai/kimi-code": patch ---- - -Recognize Kimi's standalone "Unsupported image." rejection so the media-stripped resend can recover stuck sessions. diff --git a/packages/agent-core-v2/src/kosong/contract/errors.ts b/packages/agent-core-v2/src/kosong/contract/errors.ts index ba09b783d3..7347afc47e 100644 --- a/packages/agent-core-v2/src/kosong/contract/errors.ts +++ b/packages/agent-core-v2/src/kosong/contract/errors.ts @@ -210,7 +210,6 @@ const IMAGE_FORMAT_PROVIDER_MESSAGE_PATTERNS = [ const IMAGE_FORMAT_STATUS_MESSAGE_PATTERNS = [ /unsupported image (?:url|format|type)/, - /unsupported image(?=\s*(?:[.!?]|$))/, /does not represent a valid image/, /could not (?:process|decode) (?:the |input )?image/, /unable to process (?:the |input )?image/, diff --git a/packages/agent-core-v2/test/app/llmProtocol/errors.test.ts b/packages/agent-core-v2/test/app/llmProtocol/errors.test.ts index 842a95001c..75905c1892 100644 --- a/packages/agent-core-v2/test/app/llmProtocol/errors.test.ts +++ b/packages/agent-core-v2/test/app/llmProtocol/errors.test.ts @@ -228,9 +228,6 @@ describe('isImageFormatError', () => { ), ).toBe(true); expect(isImageFormatError(new APIStatusError(400, 'unsupported image format'))).toBe(true); - expect( - isImageFormatError(new APIStatusError(400, 'Unsupported image. Please try another one.')), - ).toBe(true); expect(isImageFormatError(new APIStatusError(400, 'Unable to process input image'))).toBe(true); expect( isImageFormatError( @@ -266,9 +263,6 @@ describe('isImageFormatError', () => { it('does not match image count/size/support errors that stripping media cannot fix', () => { expect(isImageFormatError(new APIStatusError(400, 'too many images in request'))).toBe(false); - expect( - isImageFormatError(new APIStatusError(400, 'unsupported image size exceeds the limit')), - ).toBe(false); expect( isImageFormatError(new APIStatusError(400, 'image dimension 5000 exceeds maximum 2048')), ).toBe(false); diff --git a/packages/kosong/src/errors.ts b/packages/kosong/src/errors.ts index 37752ddca5..1ad2c00742 100644 --- a/packages/kosong/src/errors.ts +++ b/packages/kosong/src/errors.ts @@ -272,11 +272,6 @@ const IMAGE_FORMAT_PROVIDER_MESSAGE_PATTERNS = [ const IMAGE_FORMAT_STATUS_MESSAGE_PATTERNS = [ // Unsupported format — OpenAI / Moonshot "unsupported image …". /unsupported image (?:url|format|type)/, - // Standalone-sentence form — Kimi "Unsupported image. …". The - // lookahead keeps the deliberate boundary: phrasings that continue into a - // qualifier ("unsupported image size …", a count/size limit) must not - // match, so only punctuation- or end-terminated occurrences classify. - /unsupported image(?=\s*(?:[.!?]|$))/, // Undecodable / corrupt image data. /does not represent a valid image/, /could not (?:process|decode) (?:the |input )?image/, diff --git a/packages/kosong/test/errors.test.ts b/packages/kosong/test/errors.test.ts index b874253410..c2ad36f898 100644 --- a/packages/kosong/test/errors.test.ts +++ b/packages/kosong/test/errors.test.ts @@ -585,10 +585,6 @@ describe('isImageFormatError', () => { ), ).toBe(true); expect(isImageFormatError(new APIStatusError(400, 'unsupported image format'))).toBe(true); - // Kimi standalone-sentence form (actual production message) - expect( - isImageFormatError(new APIStatusError(400, 'Unsupported image. Please try another one.')), - ).toBe(true); // Gemini expect(isImageFormatError(new APIStatusError(400, 'Unable to process input image'))).toBe(true); expect( @@ -628,11 +624,6 @@ describe('isImageFormatError', () => { // model blind to the user's images — hiding the real error. They must // surface instead of triggering a media-stripped resend. expect(isImageFormatError(new APIStatusError(400, 'too many images in request'))).toBe(false); - // Qualifier-continuing phrasing: the standalone-sentence pattern must - // not swallow count/size variants of "unsupported image …". - expect( - isImageFormatError(new APIStatusError(400, 'unsupported image size exceeds the limit')), - ).toBe(false); expect( isImageFormatError(new APIStatusError(400, 'image dimension 5000 exceeds maximum 2048')), ).toBe(false);