Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(assistantUiMessages): handle missing assistant messages gracefully

Steven Enamakel1c32ac29d632
diff --git a/app/src/providers/assistantUiMessages.ts b/app/src/providers/assistantUiMessages.ts
index 1fc482a995..07f7d6ba3b 100644
--- a/app/src/providers/assistantUiMessages.ts
+++ b/app/src/providers/assistantUiMessages.ts
@@ -130,7 +130,15 @@ function assistantParts(
}
for (const entry of [...timeline].sort((a, b) => a.seq - b.seq)) {
- if (!emittedToolIds.has(entry.id)) parts.push(toolPart(entry));
+ // The `has` check also stands in for id uniqueness across the timeline
+ // itself, not just against the transcript pass above. assistant-ui keys
+ // tool parts as `toolCallId-${id}` and *throws* on a repeat ("Duplicate key
+ // … in useResources"), taking the thread render down — so a duplicate has
+ // to be dropped here rather than trusted not to occur. The slice no longer
+ // mints colliding ids, but threads persisted before that fix still can.
+ if (emittedToolIds.has(entry.id)) continue;
+ emittedToolIds.add(entry.id);
+ parts.push(toolPart(entry));
}
if (text.length > 0) parts.push({ type: 'text', text });
return parts;