Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge branch 'main' into fix-5012-openai-compat-retry

Saim Shafiqueb36d3ecbed89
diff --cc server/drivers/openai-chat.ts
index 6a93897dab,d7975c4c90..d3df0af17a
--- a/server/drivers/openai-chat.ts
+++ b/server/drivers/openai-chat.ts
@@@ -678,10 -674,10 +676,10 @@@ export function createOpenAIChatRuntime
break;
} catch (value) {
const error = asError(value);
- const verdict = classifyError(error);
+ const verdict = classifyError(error, { openAi: isOpenAIAddress(options.apiUrl) });
- // A provider refuses a request with too many tools before running anything: learn its limit and list fewer.
- const refit = streamed || seenCalls.size || abort.signal.aborted ? undefined : await refitChatTools(tools, error, chatToolLimitKey(options.apiUrl, model), [ASK_USER_TOOL_DEFINITION]);
- if (refit) {
+ // Refused for too many tools, nothing ran: learn the limit and list fewer (after a call only when servers just joined).
+ const listedBefore = tools.definitions.length, refit = streamed || (seenCalls.size && !joined) || abort.signal.aborted ? undefined : await refitChatTools(tools, error, chatToolLimitKey(options.apiUrl, model), [ASK_USER_TOOL_DEFINITION]);
+ if (refit && tools.definitions.length < listedBefore) {
for (const message of refit) emit({ ...base(turn.threadId, turnId), type: "runtime.notice", message: safeText(message) });
noteToolBudget(turn.botId, tools.budget);
emit({ ...base(turn.threadId, turnId), type: "turn.retrying", attempt: 1, delayMs: 0, reason: "tool_limit" });