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:
commit
754157fd88
|
|
@ -26,7 +26,7 @@ import {
|
||||||
createFileStateCacheWithSizeLimit,
|
createFileStateCacheWithSizeLimit,
|
||||||
type FileStateCache,
|
type FileStateCache,
|
||||||
} from './fileStateCache.js'
|
} from './fileStateCache.js'
|
||||||
import { isNotEmptyMessage, normalizeMessages } from './messages.js'
|
import { isNotEmptyMessage, isThinkingMessage, normalizeMessages } from './messages.js'
|
||||||
import { expandPath } from './path.js'
|
import { expandPath } from './path.js'
|
||||||
import type {
|
import type {
|
||||||
inputSchema as permissionToolInputSchema,
|
inputSchema as permissionToolInputSchema,
|
||||||
|
|
@ -117,6 +117,13 @@ export function* normalizeMessage(message: Message): Generator<SDKMessage> {
|
||||||
if (!isNotEmptyMessage(_)) {
|
if (!isNotEmptyMessage(_)) {
|
||||||
continue
|
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 {
|
yield {
|
||||||
type: 'assistant',
|
type: 'assistant',
|
||||||
message: _.message,
|
message: _.message,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user