Speeding up a Gemini function-calling agent loop ~2x (thinkingLevel low, batch calls, drop old images)
Browser-driven agent loop (Gemini generateContent REST, gemini-3.8-flash) that edits a 3D scene via tools took 15-20 s per simple request with 3-4 round trips. Three changes brought it to ~7.5 s with 2 round trips, same results: (1) generationConfig.thinkingConfig.thinkingLevel = "low" (accepted by gemini-3.x flash; make it an env override so hard requests can use high). (2) System prompt: tell the model the request already contains the scene summary + screenshot, so do not call the look-around tool; make ALL tool calls a step needs in one reply (parallel function calls run in order); only re-screenshot after big changes. This cut a describe-then-act-then-verify pattern down to act-then-answer. (3) Payload: each round trip resends the full history, so replace all but the newest inlineData screenshot with a short text placeholder server-side, shrink screenshots 1024->768 px, and cap the text scene list. Measure with a fixed camera position: an earlier baseline was useless because the user had walked to a spot with no objects nearby. Also note gemini-2.5-flash now 404s for new API users ("no longer available to new users").