GEMINI LABJP
ROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 termsROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 terms
Back to Blog

Building an Autonomous Agent with Gemini 3 Flash Function Calling

geminifunction-callingagentgoogle-searchdev-notes

Introduction

Since Gemini 3 Flash launched, I'd been wanting to try something: building an autonomous agent that combines Function Calling with Google Search grounding.

I finally got around to it over the weekend, and it worked better than expected. Here's what I built, and what I learned.

What I Built

A "news aggregator agent" that auto-generates summary reports on a given topic.

The user provides a topic (e.g., "latest AI regulation developments"), and the agent automatically:

  1. Fetches real-time info via Google Search
  2. Synthesizes information from multiple sources
  3. Generates a structured report
  4. Appends a source list at the end

The whole thing came in around 200 lines of Python.

How Function Calling Works

The Gemini API's Function Calling flow is straightforward:

  1. Pass tool definitions to the model
  2. The model returns a "please call this tool" response
  3. Your app executes the tool and returns results
  4. The model generates the final answer

This back-and-forth is the core of Function Calling — the model decides what to do, but you control how it's executed.

Key Learnings

1. Tool description quality is everything

Vague tool descriptions lead to the model calling tools at the wrong time. Being explicit about when to use it, what goes in, and what comes back significantly improved accuracy.

tools = [
    {
        "name": "search_web",
        "description": "Search the web for a query and retrieve up-to-date information. Use when the user needs current events, recent data, or real-time information.",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search query (English or Japanese)"
                }
            },
            "required": ["query"]
        }
    }
]

2. Function Calling vs. Google Search Grounding

The Gemini API also offers "Google Search Grounding" where the model searches automatically. The difference:

  • Google Search Grounding: Model searches autonomously. Minimal code required.
  • Function Calling: You define and control the tools. Enables multiple tool combinations and custom API integrations.

I chose Function Calling because I wanted flexibility to add internal API integrations later.

3. Higher thinking budget improves tool selection

Setting thinking_budget to high noticeably improved the model's judgment about when to call tools. For cost-sensitive use cases, medium was good enough.

4. Always limit loop steps

Add a maximum step count to prevent runaway tool-calling loops. During testing, I ran up an unexpected API bill without this guardrail.

MAX_STEPS = 5
for step in range(MAX_STEPS):
    response = model.generate_content(messages, tools=tools)
    if not response.candidates[0].function_calls:
        break  # No tool call → final answer
    # Execute tool → append result to messages

Why Gemini 3 Flash for Agents

Gemini 3 Flash turned out to be the right choice for agentic use cases:

  • Speed: Agents have many roundtrips, so slow responses kill the UX
  • Cost: $0.50/1M input tokens stays realistic even with loops
  • Function Calling accuracy: SWE-bench 78% translates to accurate tool selection

Compared to Gemini 3.1 Pro, the cost difference is significant while performance for this use case is on par. For agents, Flash is the pragmatic choice.

What's Next

  • Multi-tool agents combining web search + email + calendar
  • Google Antigravity integration for fully autonomous workflows
  • Streaming support to show the agent's "thinking" in real time

Function Calling turned out to be simpler to implement than I expected, with a wide range of applications. Expect more concrete agent implementation articles on Gemini Lab soon.