Skip to content

Commit 658038b

Browse files
hydrate block state on server side output
1 parent 9ae6209 commit 658038b

File tree

6 files changed

+42
-22
lines changed

6 files changed

+42
-22
lines changed

apps/sim/executor/execution/block-executor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export class BlockExecutor {
110110
}
111111

112112
resolvedInputs = this.resolver.resolveInputs(ctx, node.id, block.config.params, block)
113-
resolvedInputs = await hydrateCacheReferences(resolvedInputs)
114113

115114
if (blockLog) {
116115
blockLog.input = this.sanitizeInputsForLog(resolvedInputs)
@@ -169,6 +168,10 @@ export class BlockExecutor {
169168
})) as NormalizedBlockOutput
170169
}
171170

171+
normalizedOutput = (await hydrateCacheReferences(
172+
normalizedOutput as Record<string, unknown>
173+
)) as NormalizedBlockOutput
174+
172175
const duration = performance.now() - startTime
173176

174177
if (blockLog) {

apps/sim/lib/paginated-cache/paginate.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ vi.mock('@/lib/paginated-cache/redis-cache', () => ({
2525
})),
2626
}))
2727

28-
import { autoPaginate, hydrateCacheReferences } from '@/lib/paginated-cache/paginate'
28+
import {
29+
autoPaginate,
30+
cleanupPaginatedCache,
31+
hydrateCacheReferences,
32+
} from '@/lib/paginated-cache/paginate'
2933
import type { ToolResponse } from '@/tools/types'
3034

3135
function makePageResponse(items: unknown[], hasMore: boolean, cursor: string | null): ToolResponse {
@@ -256,7 +260,6 @@ describe('cleanupPaginatedCache', () => {
256260
.mockResolvedValueOnce(['0', ['pagcache:page:exec-1:tool:field:uuid:0']])
257261
.mockResolvedValueOnce(['0', ['pagcache:meta:exec-1:tool:field:uuid']])
258262

259-
const { cleanupPaginatedCache } = await import('@/lib/paginated-cache/paginate')
260263
await cleanupPaginatedCache('exec-1')
261264

262265
expect(mockScan).toHaveBeenCalledWith('0', 'MATCH', 'pagcache:page:exec-1:*', 'COUNT', 100)
@@ -267,7 +270,6 @@ describe('cleanupPaginatedCache', () => {
267270
it('no-ops when Redis is unavailable', async () => {
268271
mockGetRedisClient.mockReturnValue(null)
269272

270-
const { cleanupPaginatedCache } = await import('@/lib/paginated-cache/paginate')
271273
await cleanupPaginatedCache('exec-1')
272274

273275
expect(mockScan).not.toHaveBeenCalled()

apps/sim/lib/workflows/executor/queued-workflow-execution.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,17 @@ export async function executeQueuedWorkflowJob(
330330
await eventWriter.close()
331331
}
332332

333-
await Promise.allSettled([
334-
cleanupExecutionBase64Cache(executionId),
335-
cleanupPaginatedCache(executionId),
336-
])
333+
await cleanupExecutionBase64Cache(executionId).catch((error) => {
334+
logger.error('Failed to cleanup queued workflow base64 cache', {
335+
executionId,
336+
error: error instanceof Error ? error.message : String(error),
337+
})
338+
})
339+
await cleanupPaginatedCache(executionId).catch((error) => {
340+
logger.error('Failed to cleanup paginated cache', {
341+
executionId,
342+
error: error instanceof Error ? error.message : String(error),
343+
})
344+
})
337345
}
338346
}

apps/sim/lib/workflows/streaming/streaming.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ export async function createStreamingResponse(
348348
controller.enqueue(encodeSSE('[DONE]'))
349349

350350
if (executionId) {
351-
await Promise.allSettled([
352-
cleanupExecutionBase64Cache(executionId),
353-
cleanupPaginatedCache(executionId),
354-
])
351+
await cleanupExecutionBase64Cache(executionId)
352+
void cleanupPaginatedCache(executionId).catch((error) => {
353+
logger.error('Failed to cleanup paginated cache', { executionId, error })
354+
})
355355
}
356356

357357
controller.close()
@@ -362,10 +362,10 @@ export async function createStreamingResponse(
362362
)
363363

364364
if (executionId) {
365-
await Promise.allSettled([
366-
cleanupExecutionBase64Cache(executionId),
367-
cleanupPaginatedCache(executionId),
368-
])
365+
await cleanupExecutionBase64Cache(executionId)
366+
void cleanupPaginatedCache(executionId).catch((error) => {
367+
logger.error('Failed to cleanup paginated cache', { executionId, error })
368+
})
369369
}
370370

371371
controller.close()
@@ -378,10 +378,14 @@ export async function createStreamingResponse(
378378
timeoutController.abort()
379379
timeoutController.cleanup()
380380
if (executionId) {
381-
await Promise.allSettled([
382-
cleanupExecutionBase64Cache(executionId),
383-
cleanupPaginatedCache(executionId),
384-
])
381+
try {
382+
await cleanupExecutionBase64Cache(executionId)
383+
} catch (error) {
384+
logger.error(`[${requestId}] Failed to cleanup base64 cache`, { error })
385+
}
386+
void cleanupPaginatedCache(executionId).catch((error) => {
387+
logger.error('Failed to cleanup paginated cache', { executionId, error })
388+
})
385389
}
386390
},
387391
})

apps/sim/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,8 @@ export async function executeTool(
852852
// Process file outputs if execution context is available
853853
finalResult = await processFileOutputs(finalResult, tool, executionContext)
854854

855+
// Auto-paginate if configured (duplicated in both directExecution and HTTP branches
856+
// because each returns independently with timing data)
855857
finalResult = await maybeAutoPaginate(
856858
tool,
857859
finalResult,

apps/sim/tools/zendesk/get_tickets_v2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ZendeskGetTicketsV2Params {
2424
export interface ZendeskGetTicketsV2Response {
2525
success: boolean
2626
output: {
27-
tickets: any[]
27+
tickets: Record<string, unknown>[]
2828
paging?: {
2929
after_cursor: string | null
3030
has_more: boolean
@@ -107,7 +107,8 @@ export const zendeskGetTicketsV2Tool: ToolConfig<
107107
type: 'string',
108108
required: false,
109109
visibility: 'user-or-llm',
110-
description: 'Results per page as a number string (default: "100", max: "100")',
110+
description:
111+
'Batch size per API request during auto-pagination as a number string (default: "100", max: "100")',
111112
},
112113
},
113114

0 commit comments

Comments
 (0)