From 70b0d4330d2e7ce76cdfc54a8dfa079b7beac935 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 16:28:37 +0000 Subject: [PATCH] fix(execution): no node:crypto import in toolRunContext; keep the Worker bundle loadable LOU-U15 (#99) imported randomUUID from node:crypto in src/execution/toolRunContext.ts, which workerd cannot load ('No such module "crypto"'), so the cloudflare 'wrangler dev serves the worker' test failed on main. Use the Worker-safe newId() helper (globalThis.crypto.randomUUID) instead; the generated id keeps the call_ prefix. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR --- src/execution/toolRunContext.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/execution/toolRunContext.ts b/src/execution/toolRunContext.ts index e1a7e96ab..22ec5ef5a 100644 --- a/src/execution/toolRunContext.ts +++ b/src/execution/toolRunContext.ts @@ -6,7 +6,7 @@ * type promises (`toolCallId`, `messages`, `abortSignal`) are always real. */ -import { randomUUID } from 'node:crypto'; +import { newId } from '../utils/id'; import type { ToolExecutionOptions } from 'ai'; import type { Message } from '../providers'; import type { RunUsage } from '../models/usage'; @@ -52,7 +52,7 @@ function transcriptBefore(messages: readonly Message[], toolCallId: string): rea * to a generated id for callers with no model turn behind the call. */ export function buildToolRunContext(input: ToolRunInput): ToolExecutionOptions & ToolRunContext { - const toolCallId = input.toolCallId ?? `call_${randomUUID()}`; + const toolCallId = input.toolCallId ?? newId('call'); const ctx = { toolCallId, messages: transcriptBefore(input.messages ?? [], toolCallId),