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);

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.

Is there a known issue where windows have to be closed to equip items?

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.

It doesn't seem to be a known issue in either the "issues" tab in this repo, nor in mineflayer. There are many other issues related to the window state that are already known, but this one is not stated anywhere that I could find. I simply hit this issue while testing the agent myself.

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.

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,
}
}