1. MALFORMED_FUNCTION_CALL — Gemini's function calling silently breaks when tool arguments contain large strings. Google acknowledged it as a P2 bug, still open. Adding a JSON-escaping instruction to the prompt cuts it by ~90%. When that's not enough, falling back to responseMimeType + responseSchema bypasses the broken code path entirely.
2. 429s with no backoff — The SDK throws but doesn't help you recover. We built an adaptive token-bucket that halves RPM on each 429 and slowly recovers, plus a circuit breaker for when the queue gets too deep.
3. JSON in markdown blocks — Even with responseMimeType: 'application/json', Gemini sometimes wraps output in ```json``` blocks. Small thing but breaks JSON.parse in production.
We extracted all three fixes into a standalone library.
Zero dependencies. TypeScript. MIT.
GitHub: https://github.com/emotix/gemini-heal npm: npm install gemini-heal