Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/agent/library/skills.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,14 @@ export async function equip(bot, itemName) {
await bot.equip(item, 'off-hand');
}
else {
await bot.equip(item, 'hand');
try {
if (bot.currentWindow) bot.closeWindow(bot.currentWindow);
Comment thread
uukelele marked this conversation as resolved.
await bot.equip(item, 'hand');
} catch (err) {
console.warn('Failed to equip tool, continuing without equip:', err.message);
log(bot, `Failed to equip ${itemName}.`);
return false;
}
}
log(bot, `Equipped ${itemName}.`);
return true;
Expand Down
46 changes: 32 additions & 14 deletions src/models/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,38 @@ export class Gemini {
});
}

const result = await this.genAI.models.generateContent({
model: this.model_name || "gemini-2.5-flash",
contents: contents,
safetySettings: this.safetySettings,
config: {
systemInstruction: systemMessage,
...(this.params || {})

const MAX_RETRIES = 5;
const RETRY_DELAY = 5000;

for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC no other providers have a built-in retry system. Does this need to be implemented specifically for Gemini? Or should there be a separate retry system at another layer for all providers?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but I only tested this with Gemini, and thus I can't really tell you whether or not this should be at another layer for all providers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, just following up on this, but does this answer your question?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm yea but i feel like we probably don't need a retry system or we could make it for example if an error is 404/401/403/400 then don't retry, only retry on 529/502/server errors

and it probably best to have retry system across all providers

try {
const result = await this.genAI.models.generateContent({
model: this.model_name || "gemini-2.5-flash",
contents: contents,
safetySettings: this.safetySettings,
config: {
systemInstruction: systemMessage,
...(this.params || {})
}
});
const response = await result.text;
if (!response) {
console.warn(`Gemini returned empty response, retrying in ${RETRY_DELAY/1000}s... (attempt ${attempt + 1}/${MAX_RETRIES})`);
await new Promise(r => setTimeout(r, RETRY_DELAY));
continue;
}
console.log('Received.');
return response;
} catch (err) {
if (attempt < MAX_RETRIES - 1 && (err.status === 503 || err.status === 429)) {
console.warn(`Google API error ${err.status}, retrying in ${RETRY_DELAY/1000}s... (attempt ${attempt + 1}/${MAX_RETRIES})`);
await new Promise(r => setTimeout(r, RETRY_DELAY));
} else {
throw err;
}
}
});
const response = await result.text;

console.log('Received.');

return response;
}
}

async sendVisionRequest(turns, systemMessage, imageBuffer) {
Expand Down Expand Up @@ -173,4 +191,4 @@ function createWavHeader(dataLength, sampleRate, channels, bitsPerSample) {

export const TTSConfig = {
sendAudioRequest: sendAudioRequest,
}
}