diff --git a/src/agents/pi-embedded-subscribe.ts b/src/agents/pi-embedded-subscribe.ts index bed69a237..16643d6fc 100644 --- a/src/agents/pi-embedded-subscribe.ts +++ b/src/agents/pi-embedded-subscribe.ts @@ -179,28 +179,22 @@ function splitThinkingTaggedText(text: string): ThinkTaggedSplitBlock[] | null { function promoteThinkingTagsToBlocks(message: AssistantMessage): void { if (!Array.isArray(message.content)) return; - const hasThinkingBlock = message.content.some((block) => { - if (!block || typeof block !== "object") return false; - return (block as Record).type === "thinking"; - }); + const hasThinkingBlock = message.content.some( + (block) => block.type === "thinking", + ); if (hasThinkingBlock) return; - const next: Array> = []; + const next: AssistantMessage["content"] = []; let changed = false; for (const block of message.content) { - if (!block || typeof block !== "object") { - next.push(block as Record); + if (block.type !== "text") { + next.push(block); continue; } - const record = block as Record; - if (record.type !== "text" || typeof record.text !== "string") { - next.push(record); - continue; - } - const split = splitThinkingTaggedText(record.text); + const split = splitThinkingTaggedText(block.text); if (!split) { - next.push(record); + next.push(block); continue; } changed = true; @@ -215,7 +209,7 @@ function promoteThinkingTagsToBlocks(message: AssistantMessage): void { } if (!changed) return; - (message as unknown as { content: unknown }).content = next; + message.content = next; } function normalizeSlackTarget(raw: string): string | undefined {