Skip to content

Commit ef358d0

Browse files
committed
agent with tool input deletion case
1 parent cc790aa commit ef358d0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

apps/sim/socket/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ async function main() {
5858
})
5959

6060
process.on('unhandledRejection', (reason, promise) => {
61+
if (reason instanceof Error && reason.message === 'The client is closed') {
62+
logger.warn('Redis client is closed — suppressing unhandled rejection')
63+
return
64+
}
6165
logger.error('Unhandled Rejection at:', promise, 'reason:', reason)
6266
})
6367

apps/sim/stores/operation-queue/store.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import { createLogger } from '@sim/logger'
22
import { create } from 'zustand'
33
import type { OperationQueueState, QueuedOperation } from './types'
44

5+
function isBlockStillPresent(blockId: string | undefined): boolean {
6+
if (!blockId) return true
7+
try {
8+
const { useWorkflowStore } = require('@/stores/workflows/workflow/store')
9+
return Boolean(useWorkflowStore.getState().blocks[blockId])
10+
} catch {
11+
return true
12+
}
13+
}
14+
515
const logger = createLogger('OperationQueue')
616

717
/** Timeout for subblock/variable operations before considering them failed */
@@ -220,6 +230,20 @@ export const useOperationQueueStore = create<OperationQueueState>((set, get) =>
220230
}
221231

222232
if (!retryable) {
233+
const targetBlockId = operation.operation.payload?.blockId || operation.operation.payload?.id
234+
if (targetBlockId && !isBlockStillPresent(targetBlockId)) {
235+
logger.debug('Dropping failed operation for deleted block', {
236+
operationId,
237+
blockId: targetBlockId,
238+
})
239+
set((s) => ({
240+
operations: s.operations.filter((op) => op.id !== operationId),
241+
isProcessing: false,
242+
}))
243+
get().processNextOperation()
244+
return
245+
}
246+
223247
logger.error(
224248
'Operation failed with non-retryable error - state out of sync, triggering offline mode',
225249
{

0 commit comments

Comments
 (0)