fix(serve): skip thinking-only message fragments to prevent duplicate response in cs-cloud
normalizeMessages() splits a multi-block AssistantMessage (e.g. [thinking, text]) into one message per content block. When serve mode emits both the thinking-only fragment and the text message as separate session.message events, cs-cloud's adaptMessageEvent creates two assistant messages (one via the streaming path, one via the non-streaming path), causing the response to appear twice in the UI. Fix: skip thinking-only normalized messages in normalizeMessage(), since the thinking content is already rendered via the stream_event path. Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
This commit is contained in:
parent
2857e77065
commit
02899ce69f
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user