agentgui 1.0.795 → 1.0.796
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +20 -9
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -2072,27 +2072,38 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
2072
2072
|
} catch (e) {}
|
|
2073
2073
|
}
|
|
2074
2074
|
|
|
2075
|
-
rateLimitState.
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2075
|
+
const existingRetryCount2 = rateLimitState.get(conversationId)?.retryCount || 0;
|
|
2076
|
+
if (existingRetryCount2 >= 3) {
|
|
2077
|
+
debugLog(`[rate-limit] Conv ${conversationId} result rate limit hit ${existingRetryCount2 + 1} times, giving up`);
|
|
2078
|
+
batcher.drain();
|
|
2079
|
+
activeExecutions.delete(conversationId);
|
|
2080
|
+
queries.setIsStreaming(conversationId, false);
|
|
2081
|
+
const errorMessage = queries.createMessage(conversationId, 'assistant', `Error: Rate limit exceeded after ${existingRetryCount2 + 1} attempts. Please try again later.`);
|
|
2082
|
+
broadcastSync({ type: 'message_created', conversationId, message: errorMessage, timestamp: Date.now() });
|
|
2083
|
+
broadcastSync({ type: 'streaming_complete', sessionId, conversationId, interrupted: true, timestamp: Date.now() });
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
rateLimitState.set(conversationId, {
|
|
2087
|
+
retryAt: Date.now() + (retryAfterSec * 1000),
|
|
2088
|
+
cooldownMs: retryAfterSec * 1000,
|
|
2089
|
+
retryCount: existingRetryCount2 + 1,
|
|
2079
2090
|
isStreamDetected: true
|
|
2080
2091
|
});
|
|
2081
|
-
|
|
2092
|
+
|
|
2082
2093
|
broadcastSync({
|
|
2083
2094
|
type: 'rate_limit_hit',
|
|
2084
2095
|
sessionId,
|
|
2085
2096
|
conversationId,
|
|
2086
2097
|
retryAfterMs: retryAfterSec * 1000,
|
|
2087
2098
|
retryAt: Date.now() + (retryAfterSec * 1000),
|
|
2088
|
-
retryCount: 1,
|
|
2099
|
+
retryCount: existingRetryCount2 + 1,
|
|
2089
2100
|
timestamp: Date.now()
|
|
2090
2101
|
});
|
|
2091
|
-
|
|
2102
|
+
|
|
2092
2103
|
batcher.drain();
|
|
2093
2104
|
activeExecutions.delete(conversationId);
|
|
2094
2105
|
queries.setIsStreaming(conversationId, false);
|
|
2095
|
-
|
|
2106
|
+
|
|
2096
2107
|
setTimeout(() => {
|
|
2097
2108
|
rateLimitState.delete(conversationId);
|
|
2098
2109
|
broadcastSync({
|
|
@@ -2102,7 +2113,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
2102
2113
|
});
|
|
2103
2114
|
scheduleRetry(conversationId, messageId, content, agentId, model, subAgent);
|
|
2104
2115
|
}, retryAfterSec * 1000);
|
|
2105
|
-
|
|
2116
|
+
|
|
2106
2117
|
return;
|
|
2107
2118
|
}
|
|
2108
2119
|
|