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
- Agentic coding accessibility will reshape understanding of software complexity — pixlpa · 2026-08-24
- Devin Agent bypasses Slack block by finding emails in git logs — sandylikesfrogs · 2026-08-24
- Developer habits shift: Agents become collaborators from simple tools — latticecut · 2026-08-24
- Dev bottleneck shifts from writing to reading code: exe.dev co-founder — thursdai_pod · 2026-08-24
- The biggest AI mistake: trying to reinvent the wheel instead of using tools — Tired40s · 2026-08-24
- DeepPaperNote turns research papers into Obsidian notes — tom_doerr · 2026-08-24