From 6ff7f42e07a6b1bf36569d6c482ad3fc3ce6d899 Mon Sep 17 00:00:00 2001 From: wasimysaid Date: Mon, 25 May 2026 23:36:44 +0200 Subject: [PATCH] Studio: scope artifact IDs by message to prevent cross-turn collisions --- studio/frontend/src/features/chat/artifacts/types.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/studio/frontend/src/features/chat/artifacts/types.ts b/studio/frontend/src/features/chat/artifacts/types.ts index 21039ff5d8..86d42fd733 100644 --- a/studio/frontend/src/features/chat/artifacts/types.ts +++ b/studio/frontend/src/features/chat/artifacts/types.ts @@ -43,11 +43,14 @@ export function hashArtifactCode(code: string): string { export function createArtifactId(input: ChatArtifactInput): string { const threadSegment = input.threadId || "no-thread"; - const sourceId = - input.sourceToolCallId || input.sourceMessageId || "transient"; - const parts = [input.source, threadSegment, sourceId]; + const messageSegment = input.sourceMessageId || "transient"; + // Backend tool call IDs (call_0, call_1, …) reset per request, so + // the message ID is needed to scope them to a specific turn. + const parts = [input.source, threadSegment, messageSegment]; - if (input.source !== "tool" || !input.sourceToolCallId) { + if (input.source === "tool" && input.sourceToolCallId) { + parts.push(input.sourceToolCallId); + } else { parts.push(hashArtifactCode(input.code)); }