Skip to content

Commit fb63dc0

Browse files
marthakellyclaude
andcommitted
fix(agent): regenerate reasoningMessageId for consecutive blocks with no SDK id
When closeReasoningIfOpen() auto-closes a prior block and a second reasoning-start arrives with id="0" or no id, the handler was silently reusing the previous reasoningMessageId. Mirror the text-start pattern: always call randomUUID() when the provider id is falsy or "0". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0b76b29 commit fb63dc0

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

packages/runtime/src/agent/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,12 +1025,13 @@ export class BuiltInAgent extends AbstractAgent {
10251025
}
10261026
case "reasoning-start": {
10271027
closeReasoningIfOpen();
1028-
// New text message starting - use the SDK-provided id
1029-
// Use randomUUID() if part.id is falsy or "0" to prevent message merging issues
1028+
// Use SDK-provided id, or generate a fresh UUID if id is falsy/"0"
1029+
// to prevent consecutive reasoning blocks from sharing a messageId
10301030
const providedId = "id" in part ? part.id : undefined;
1031-
if (providedId && providedId !== "0") {
1032-
reasoningMessageId = providedId as typeof reasoningMessageId;
1033-
}
1031+
reasoningMessageId =
1032+
providedId && providedId !== "0"
1033+
? (providedId as typeof reasoningMessageId)
1034+
: randomUUID();
10341035
const reasoningStartEvent: ReasoningStartEvent = {
10351036
type: EventType.REASONING_START,
10361037
messageId: reasoningMessageId,

0 commit comments

Comments
 (0)