Practical technical guides

Google Gen AI Python SDK 3.7 Returns the Call ID in Automatic Function Calling

Released December 2, 2026: function responses now carry the id of their call. Measured on 3.6.1 and 3.7.0 with a mock transport, and what to change.

By Sandeep Belgavi · Published 2026-12-06

What changed on December 2, 2026

Version 3.7.0 of the Google Gen AI Python SDK (google-genai), released on December 2, 2026, lists among its bug fixes: "Pass the function call id to the function response in automatic function calling". The commit, feb88ba, dated November 24, 2026, closes issue 3192, which was opened on October 22, 2026. The change is three lines in the SDK's automatic function calling code plus a new optional id parameter on types.Part.from_function_response.

The issue explains why it matters. In the SDK's own type definitions, FunctionCall.id asks the client to return the response with the matching id, and FunctionResponse.id is documented as populated by the client to match the corresponding function call id. Before 3.7.0, when the SDK ran tools for you, it built each FunctionResponse from the function name and result only. If the model asked for two calls to the same function in one turn, the follow-up request carried two responses with the same name and no way to tell which answered which, other than their order.

Measured: 3.6.1 against 3.7.0

I installed both versions into separate uv environments with --exclude-newer 2026-12-06T23:59:59Z and ran the same offline probe in each. The probe defines a tool for Belgavi's Book Store, order_status(order_id), and serves both model turns from an httpx2.MockTransport (the 3.x SDK uses the httpx2 package). The first mocked response asks for two parallel calls, call_a for order B-1001 and call_b for B-1002; the second returns text. The ids in the mocked response are written by hand, as in the issue; no live model response was captured. The probe records the request the SDK sends after running the tools.

{"genai": "3.6.1", "responses": [{"name": "order_status", "id": null, "response": {"result": "shipped"}},
                                  {"name": "order_status", "id": null, "response": {"result": "packing"}}]}
{"genai": "3.7.0", "responses": [{"name": "order_status", "id": "call_a", "response": {"result": "shipped"}},
                                  {"name": "order_status", "id": "call_b", "response": {"result": "packing"}}]}

On 3.6.1 the two function responses are identical apart from their payloads. On 3.7.0 each carries the id of the call it answers. Both versions made exactly two HTTP requests and produced the same final text in this probe, because the mocked model does not depend on the ids. A real model may: when it cannot pair results with calls, it can only rely on position, and position is exactly what breaks when results are reordered, filtered or merged.

Why ids matter more than order

Order-based pairing is fragile in three common situations.

Parallel execution. If tools run concurrently and results are appended as they finish, the order of responses can differ from the order of calls. With ids, the model and any downstream tooling can pair them regardless.

Partial results. If one call fails and your code drops it, or turns it into an error response placed at the end, position-based pairing silently attaches the wrong result to the wrong question. A help-desk agent then tells the customer that B-1002 has shipped.

History rewriting. Code that trims, summarises or replays conversation history moves parts around. Ids survive that; positions do not.

In 3.7.0, the sync and async helpers that run tools for AFC iterate over the response parts one at a time and append each result in that order, so before 3.7.0 the pairing happened to be correct in the SDK's own loop as long as nothing else touched the history. The risk was in what the history looked like to everything else: a model that expects ids, logs that join calls to results, evaluation tooling, and code that later edits the history.

What to do in your code

If you use automatic function calling, upgrade to 3.7.0 or later and check that your tests assert on ids, not only on names. The SDK prints a warning when AFC runs through Models.generate_content directly, recommending AFC through Chat.send_message instead; that recommendation is separate from this fix.

If you run the loop yourself, which most agent frameworks do, copy the id explicitly. In 3.7.0 the helper accepts it:

from google.genai import types

def response_parts(function_calls, results_by_id):
    """Build one FunctionResponse per call, paired by id; fail loudly on a missing id."""
    parts = []
    for call in function_calls:
        if call.id is None:
            raise ValueError("model returned a function call without an id; pair by position only if documented")
        parts.append(types.Part.from_function_response(
            name=call.name, response=results_by_id[call.id], id=call.id))
    return parts

On versions before 3.7.0, from_function_response has no id parameter; construct types.FunctionResponse(name=..., response=..., id=...) and wrap it in types.Part(function_response=...) instead. That is what the fixed helper now does internally.

If ids can be missing, decide what to do. Some models and some API paths may not populate FunctionCall.id. The type allows None. A loop that requires ids should fail loudly when they are absent rather than inventing them; a loop that can fall back to position should document that it does, and should not reorder results in that mode.

Checking a running system

Two quick checks tell you whether you were exposed. First, find every place that builds function responses: search for from_function_response, FunctionResponse( and any framework wrapper around them. Second, in recorded traffic or traces, look for turns with two or more function calls to the same name; those are the turns where pairing by name was ambiguous before the fix.

Upgrade notes

The change adds an optional parameter and an extra field in a request, so it is backwards compatible for callers. Two things are worth checking before rolling it out:

  • Recorded fixtures. Tests that replay recorded requests or compare request bodies will see a new id field in function responses and fail. Update the fixtures; the new field is the correct behaviour.
  • Proxies and gateways that validate or rewrite request bodies should pass the field through. If a gateway strips unknown fields, the fix will not reach the model.

The same release adds other function calling features, among them stream_function_call_arguments in GenerationConfig and support for server-side tool invocations on the Gemini platform. Those are new capabilities with their own documentation; this article covers only the id fix.

How this interacts with frameworks built on the SDK

Agent frameworks that call Gemini through google-genai usually disable the SDK's automatic function calling and run their own loop, because they need hooks for approvals, tracing and state. In those frameworks the relevant question is whether the framework copies FunctionCall.id into the response it builds, not which SDK version is installed. Upgrading the SDK alone changes nothing for them. Check the framework's own code or release notes, and test with two parallel calls to the same tool, which is the case that exposes missing ids.

Conversely, code that mixes paths, using AFC for simple tools and a hand-written loop for tools that need approval, can end up with some responses carrying ids and some not within one conversation. That is legal for the API, but it makes logs and evaluation tooling inconsistent. Pick one rule, ids always when the call has one, and enforce it in a single helper that every path uses.

Failure modes this removes, and one it does not

The fix removes mispairing for clients that rely on the SDK's AFC loop and for anything that reads that history afterwards. It does not make ids unique across turns: the SDK copies whatever id the model returned, and uniqueness beyond one response is not something the SDK promises, so code that builds a map of ids across a whole conversation should key by turn and id together. It also does not help code that bypasses get_function_response_parts and builds responses by hand without an id; that code needs the change above.

Verification

The companion example contains the probe used here, pinned requirement files for both versions, and a test that fails if any function response lacks the id of its call. Run it against the version you deploy. In production traces, count function responses without ids per SDK version; after the upgrade that count should be zero for AFC paths, and any remaining ones point at hand-written loops.

Primary references and authorship

Sources read December 6, 2026. Original explanations, measurements and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/genai_afc_response_id. Views are my own and do not represent any employer, past or present.