Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

⚡️ perf(agent-runtime): stop padding sub-second QStash step delays to a full second (#16688)

Arvin Xu2a3a8b20546e
diff --git a/apps/server/src/services/queue/impls/qstash.ts b/apps/server/src/services/queue/impls/qstash.ts
index 1c6c57bc870..83b78c4961d 100644
--- a/apps/server/src/services/queue/impls/qstash.ts
+++ b/apps/server/src/services/queue/impls/qstash.ts
@@ -45,7 +45,10 @@ export class QStashQueueServiceImpl implements QueueServiceImpl {
stepIndex,
timestamp: Date.now(),
},
- delay: Math.ceil(delay / 1000), // Convert milliseconds to seconds
+ // QStash delay granularity is whole seconds, so sub-second step delays
+ // can't be expressed. Ceiling them up padded every step to a full second;
+ // instead dispatch immediately (0) and only delay for >= 1s intents.
+ delay: delay >= 1000 ? Math.round(delay / 1000) : 0,
headers: {
'Content-Type': 'application/json',
'X-Agent-Operation-Id': operationId,