mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:04:32 +00:00
fix(agents): guard promoteThinkingTagsToBlocks against malformed content entries (#35143)
Merged via squash.
Prepared head SHA: 3971122f5f
Co-authored-by: Sid-Qin <201593046+Sid-Qin@users.noreply.github.com>
Co-authored-by: shakkernerd <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
This commit is contained in:
@@ -333,7 +333,9 @@ export function promoteThinkingTagsToBlocks(message: AssistantMessage): void {
|
||||
if (!Array.isArray(message.content)) {
|
||||
return;
|
||||
}
|
||||
const hasThinkingBlock = message.content.some((block) => block.type === "thinking");
|
||||
const hasThinkingBlock = message.content.some(
|
||||
(block) => block && typeof block === "object" && block.type === "thinking",
|
||||
);
|
||||
if (hasThinkingBlock) {
|
||||
return;
|
||||
}
|
||||
@@ -342,6 +344,10 @@ export function promoteThinkingTagsToBlocks(message: AssistantMessage): void {
|
||||
let changed = false;
|
||||
|
||||
for (const block of message.content) {
|
||||
if (!block || typeof block !== "object" || !("type" in block)) {
|
||||
next.push(block);
|
||||
continue;
|
||||
}
|
||||
if (block.type !== "text") {
|
||||
next.push(block);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user