MCPcopy
hub / github.com/simstudioai/sim / completeAsyncToolCall

Function completeAsyncToolCall

apps/sim/lib/copilot/async-runs/repository.ts:374–401  ·  view source on GitHub ↗
(input: {
  toolCallId: string
  status: Extract<CopilotAsyncToolStatus, 'completed' | 'failed' | 'cancelled'>
  result?: AsyncCompletionData | null
  error?: string | null
})

Source from the content-addressed store, hash-verified

372}
373
374export async function completeAsyncToolCall(input: {
375 toolCallId: string
376 status: Extract<CopilotAsyncToolStatus, 'completed' | 'failed' | 'cancelled'>
377 result?: AsyncCompletionData | null
378 error?: string | null
379}) {
380 const existing = await getAsyncToolCall(input.toolCallId)
381
382 if (!existing) {
383 logger.warn('completeAsyncToolCall called before pending row existed', {
384 toolCallId: input.toolCallId,
385 status: input.status,
386 })
387 return null
388 }
389
390 if (isTerminalAsyncStatus(existing.status) || isDeliveredAsyncStatus(existing.status)) {
391 return existing
392 }
393
394 return markAsyncToolStatus(input.toolCallId, input.status, {
395 claimedBy: null,
396 claimedAt: null,
397 result: input.result ?? null,
398 error: input.error ?? null,
399 completedAt: new Date(),
400 })
401}
402
403export async function markAsyncToolDelivered(toolCallId: string) {
404 return markAsyncToolStatus(toolCallId, ASYNC_TOOL_STATUS.delivered, {

Callers 4

repository.test.tsFile · 0.90
forceFailHungToolCallFunction · 0.90
updateToolCallStatusFunction · 0.90

Calls 5

isTerminalAsyncStatusFunction · 0.90
isDeliveredAsyncStatusFunction · 0.90
getAsyncToolCallFunction · 0.85
markAsyncToolStatusFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected