Gemini CLI Fix: Preserve Empty Text Turns with Tool Calls or Media
DavidAPierce · ghdev · 2026-08-19
This PR refines chat history validation in isValidContent to preserve model turns containing empty text parts (text: '') when they carry crucial structured payloads like tool requests, responses, or multimodal media.
Context:
- Previously, any turn with an empty text part was stripped entirely. While filtering broken turns, this introduced a bug in tool execution flows.
- Tool calls (functionCall) and responses (functionResponse) often have empty text fields. Stripping these breaks the conversation graph and context flow.
Changes:
- Updated isValidContent to check for other valid properties (e.g., functionCall, functionResponse, inlineData) before invalidating an empty text part.
- Added unit tests to assert preservation of valid metadata turns while pruning truly empty ones.
More from coding & agent
- Six-month prediction: hiring for generic agent harnesses built from scratch will cool — yi111 · 2026-10-16
- Omarchy ISO wouldn't boot on NVIDIA, so he had Claude patch it — indragie · 2026-10-16
- Dev uses Grok to clean up 3D printer firmware, catches it sneaking in nonsense code — yacineMTB · 2026-10-16
- A rude AI agent took 89% of a shared resource in 102-run multi-agent personality experiment — Brave-History-6502 · 2026-10-16
- Guardrails can make risky delegation work — but it takes a full-time team, says iandanforth — iandanforth · 2026-10-16
- What can you truly delegate? Only tasks with unambiguous, verifiable results — iandanforth · 2026-10-16