Skip to content

fix: retry on Gemini API errors and handle equip error while a window is open#794

Open
Austin-Lee02 wants to merge 2 commits into
mindcraft-bots:developfrom
Austin-Lee02:fix/gemini-retry-and-window-crash-fix
Open

fix: retry on Gemini API errors and handle equip error while a window is open#794
Austin-Lee02 wants to merge 2 commits into
mindcraft-bots:developfrom
Austin-Lee02:fix/gemini-retry-and-window-crash-fix

Conversation

@Austin-Lee02

@Austin-Lee02 Austin-Lee02 commented Jun 15, 2026

Copy link
Copy Markdown

This PR contains two small bug fixes:

1. Gemini API retry logic (src/models/gemini.js)
The Gemini API occasionally returns 503 (service unavailable), 429 (rate limited), or an empty response, especially under load with multiple agents running. Previously this caused the agent to crash or silently fail. This adds a retry loop of up to 5 attempts with a 5 second delay between each. The number 5 is rather arbitrary, but I found that the agents usually never exceeded even 3 calls, so 5 calls was just a number I thought was safe, but not ridiculously large as to cause the agent to wait forever.
Edit: I am running with Gemini 2.5 Flash-Lite (for context)

2. Equip crash with open window (src/agent/library/skills.js)
Calling bot.equip(item, 'hand') throws when the bot has a container window open (e.g. a chest). This closes any open window before equipping to hand, and wraps the call in a try/ catch so the agent can recover gracefully instead of crashing. I stumbled into this bug while just having a single agent attempting to progress in a world. This didn't happen often, but it did happen. The most common case I found was with a crafting table and attempting to equip a tool.

P.S. My apologies if this isn't super well written. This is my first PR and doing something like this to be honest! I would love any feedback!! :D

Add error handling when equipping items while a window is open. If it still errors, then gracefully fail and log failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant