Merge pull request #114 from Askhz/fix/thinking-model-duplicate-response

fix(serve): skip thinking-only message fragments to prevent duplicate response in cs-cloud
This commit is contained in:
DoSun 2026-05-15 18:12:58 +08:00 committed by GitHub
commit 754157fd88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,7 @@ import {
createFileStateCacheWithSizeLimit,
type FileStateCache,
} from './fileStateCache.js'
import { isNotEmptyMessage, normalizeMessages } from './messages.js'
import { isNotEmptyMessage, isThinkingMessage, normalizeMessages } from './messages.js'
import { expandPath } from './path.js'
import type {
inputSchema as permissionToolInputSchema,
@ -117,6 +117,13 @@ export function* normalizeMessage(message: Message): Generator<SDKMessage> {
if (!isNotEmptyMessage(_)) {
continue
}
// Skip thinking-only messages: normalizeMessages splits a multi-block
// AssistantMessage (e.g. [thinking, text]) into one message per block.
// Emitting the thinking-only fragment causes serve mode to send a second
// session.message event, which cs-cloud renders as a duplicate response.
if (isThinkingMessage(_)) {
continue
}
yield {
type: 'assistant',
message: _.message,