Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/sim/lib/copilot/orchestrator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export async function orchestrateCopilotStream(
runId,
messageId,
})
const continuationWorkerId = `sim-resume:${crypto.randomUUID()}`
const withLogContext = (message: string) =>
appendCopilotLogContext(message, {
requestId: context.requestId,
Expand Down Expand Up @@ -253,7 +254,7 @@ export async function orchestrateCopilotStream(
for (;;) {
claimedToolCallIds = []
claimedByWorkerId = null
const resumeWorkerId = continuation.runId || context.runId || context.messageId
const resumeWorkerId = continuationWorkerId
const readyTools: ReadyContinuationTool[] = []
const localPendingPromises: Promise<unknown>[] = []
const missingToolCallIds: string[] = []
Expand All @@ -272,6 +273,7 @@ export async function orchestrateCopilotStream(
{
toolCallId,
runId: continuation.runId,
workerId: resumeWorkerId,
}
)
continue
Expand All @@ -287,6 +289,7 @@ export async function orchestrateCopilotStream(
{
toolCallId,
runId: continuation.runId,
workerId: resumeWorkerId,
claimedBy: durableRow.claimedBy,
}
)
Expand Down Expand Up @@ -355,6 +358,7 @@ export async function orchestrateCopilotStream(
{
checkpointId: continuation.checkpointId,
runId: continuation.runId,
workerId: resumeWorkerId,
retry: resumeRetries,
missingToolCallIds,
}
Expand Down Expand Up @@ -385,6 +389,7 @@ export async function orchestrateCopilotStream(
{
checkpointId: continuation.checkpointId,
runId: continuation.runId,
workerId: resumeWorkerId,
retry: resumeRetries,
}
)
Expand Down Expand Up @@ -424,6 +429,7 @@ export async function orchestrateCopilotStream(
{
checkpointId: continuation.checkpointId,
runId: continuation.runId,
workerId: resumeWorkerId,
newlyClaimedToolCallIds,
claimFailures,
}
Expand All @@ -439,6 +445,7 @@ export async function orchestrateCopilotStream(
logger.info(withLogContext('Retrying async resume after claim contention'), {
checkpointId: continuation.checkpointId,
runId: continuation.runId,
workerId: resumeWorkerId,
retry: resumeRetries,
claimFailures,
})
Expand Down Expand Up @@ -469,6 +476,7 @@ export async function orchestrateCopilotStream(
logger.info(withLogContext('Resuming async tool continuation'), {
checkpointId: continuation.checkpointId,
runId: continuation.runId,
workerId: resumeWorkerId,
toolCallIds: readyTools.map((tool) => tool.toolCallId),
})

Expand Down
Loading