Skip to content

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

fix(chatRuntimeSlice): handle missing runtime in state guard

Steven Enamakel181547cc17b6
diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.ts
index 369fd26ce3..83bae235d6 100644
--- a/app/src/store/chatRuntimeSlice.ts
+++ b/app/src/store/chatRuntimeSlice.ts
@@ -1203,7 +1203,18 @@ const chatRuntimeSlice = createSlice({
displayDetail?: string;
}>
) => {
- const { threadId, round, toolName, toolCallId, displayLabel, displayDetail } = action.payload;
+ const { threadId, round, toolName, displayLabel, displayDetail } = action.payload;
+ // Normalise an absent id to `undefined` *before* anything reads it. A
+ // provider that sends `tool_call_id: ""` is saying "no id", but `??` only
+ // falls back on null/undefined — so the empty string used to survive as
+ // the row id, and every such call in a turn got the same one. Downstream
+ // that is fatal, not cosmetic: assistant-ui keys message parts as
+ // `toolCallId-${id}`, so two id-less calls collide on the literal key
+ // `toolCallId-` and `useResources` throws "Duplicate key toolCallId-",
+ // taking the whole thread render down. The two guards below already
+ // treated `""` as absent (both are truthiness checks); only the id
+ // fallback disagreed.
+ const toolCallId = action.payload.toolCallId || undefined;
const entries = (state.toolTimelineByThread[threadId] ??= []);
const existingIdx = toolCallId ? entries.findIndex(e => e.id === toolCallId) : -1;
// Stable row id, shared with the processing-transcript tool pointer so the
@@ -1258,7 +1269,11 @@ const chatRuntimeSlice = createSlice({
failure?: unknown;
}>
) => {
- const { threadId, round, toolName, toolCallId, success, output, failure } = action.payload;
+ const { threadId, round, toolName, success, output, failure } = action.payload;
+ // Same normalisation as `toolCallReceived` — an empty id must not match a
+ // row whose id is the generated fallback, and must fall through to the
+ // name+round scan below.
+ const toolCallId = action.payload.toolCallId || undefined;
const entries = state.toolTimelineByThread[threadId];
if (!entries || entries.length === 0) return;
const status: ToolTimelineEntryStatus = success ? 'success' : 'error';