From 5ff7951e187d75e9413860a7809d569e45cdf027 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Feb 2026 11:50:20 +0000 Subject: [PATCH] fix(run-engine): create message key when dequeuing V3 messages for execution For V3 optimized format, we now create the message key when the run is dequeued from the worker queue (ready to execute). This allows ack/nack/readMessage to work correctly. Storage savings come from not having message keys while messages are PENDING in the queue backlog - only executing runs have message keys. https://claude.ai/code/session_01AyzQp6tbj7th5QRTCYjJR5 --- internal-packages/run-engine/src/run-queue/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal-packages/run-engine/src/run-queue/index.ts b/internal-packages/run-engine/src/run-queue/index.ts index a92850327..76421ba6b 100644 --- a/internal-packages/run-engine/src/run-queue/index.ts +++ b/internal-packages/run-engine/src/run-queue/index.ts @@ -2373,6 +2373,12 @@ export class RunQueue { const descriptor = this.keys.descriptorFromQueue(decoded.queueKey); const message = reconstructMessageFromWorkerEntry(decoded, descriptor); + // For V3 format: create the message key now that the run is executing. + // This allows ack/nack to work (they read from message key). + // Storage savings come from not having message keys for PENDING runs (the backlog). + const messageKey = this.keys.messageKey(descriptor.orgId, message.runId); + await this.redis.set(messageKey, JSON.stringify(message)); + // Update the currentDequeued sets (this is done in the Lua script for legacy) const queueCurrentDequeuedKey = this.keys.queueCurrentDequeuedKeyFromQueue(decoded.queueKey); const envCurrentDequeuedKey = this.keys.envCurrentDequeuedKeyFromQueue(decoded.queueKey);