@@ -126,6 +126,7 @@ export async function orchestrateCopilotStream(
126126 runId,
127127 messageId,
128128 } )
129+ const continuationWorkerId = `sim-resume:${ crypto . randomUUID ( ) } `
129130 const withLogContext = ( message : string ) =>
130131 appendCopilotLogContext ( message , {
131132 requestId : context . requestId ,
@@ -253,7 +254,7 @@ export async function orchestrateCopilotStream(
253254 for ( ; ; ) {
254255 claimedToolCallIds = [ ]
255256 claimedByWorkerId = null
256- const resumeWorkerId = continuation . runId || context . runId || context . messageId
257+ const resumeWorkerId = continuationWorkerId
257258 const readyTools : ReadyContinuationTool [ ] = [ ]
258259 const localPendingPromises : Promise < unknown > [ ] = [ ]
259260 const missingToolCallIds : string [ ] = [ ]
@@ -272,6 +273,7 @@ export async function orchestrateCopilotStream(
272273 {
273274 toolCallId,
274275 runId : continuation . runId ,
276+ workerId : resumeWorkerId ,
275277 }
276278 )
277279 continue
@@ -287,6 +289,7 @@ export async function orchestrateCopilotStream(
287289 {
288290 toolCallId,
289291 runId : continuation . runId ,
292+ workerId : resumeWorkerId ,
290293 claimedBy : durableRow . claimedBy ,
291294 }
292295 )
@@ -355,6 +358,7 @@ export async function orchestrateCopilotStream(
355358 {
356359 checkpointId : continuation . checkpointId ,
357360 runId : continuation . runId ,
361+ workerId : resumeWorkerId ,
358362 retry : resumeRetries ,
359363 missingToolCallIds,
360364 }
@@ -385,6 +389,7 @@ export async function orchestrateCopilotStream(
385389 {
386390 checkpointId : continuation . checkpointId ,
387391 runId : continuation . runId ,
392+ workerId : resumeWorkerId ,
388393 retry : resumeRetries ,
389394 }
390395 )
@@ -424,6 +429,7 @@ export async function orchestrateCopilotStream(
424429 {
425430 checkpointId : continuation . checkpointId ,
426431 runId : continuation . runId ,
432+ workerId : resumeWorkerId ,
427433 newlyClaimedToolCallIds,
428434 claimFailures,
429435 }
@@ -439,6 +445,7 @@ export async function orchestrateCopilotStream(
439445 logger . info ( withLogContext ( 'Retrying async resume after claim contention' ) , {
440446 checkpointId : continuation . checkpointId ,
441447 runId : continuation . runId ,
448+ workerId : resumeWorkerId ,
442449 retry : resumeRetries ,
443450 claimFailures,
444451 } )
@@ -469,6 +476,7 @@ export async function orchestrateCopilotStream(
469476 logger . info ( withLogContext ( 'Resuming async tool continuation' ) , {
470477 checkpointId : continuation . checkpointId ,
471478 runId : continuation . runId ,
479+ workerId : resumeWorkerId ,
472480 toolCallIds : readyTools . map ( ( tool ) => tool . toolCallId ) ,
473481 } )
474482
0 commit comments