Gemini tool retrieval + Code Mode cuts agent input tokens from 564K to 30K on the same task

Prompt Engineering · youtube · 2026-11-30

A walkthrough of combining Gemini API tool retrieval (toolsearch, deferloading) with Code Mode (executing code against MCP tools so raw results stay out of the context window), plus file slicing for PDFs and spreadsheets. The author's demo agent dropped input tokens from 564,000 to 30,000 with the same correct answer, and guidance is given on when to use retrieval vs code mode. Demo code is open-sourced; the author discloses they recently joined Google.

Original post →

More from coding & agent

coding & agent channel →