FUNCTION CALLING · SCHEMA AND MODE

Function calling: structured arguments into a local function

Take one model-proposed function call through a declared schema, the function calling mode and argument validation before a local function runs.

Computed experiment · sixty inspection seconds

Your experiment

The model proposes get_forecast with unit "kelvin", which the declaration does not allow, and nothing validates it. The function runs and returns Celsius numbers labelled kelvin. Turn on strict validation, then try each malformed call, the coercing validator and the three modes.

Play replays the computed run over sixty inspection seconds; Next event steps, Restart rewinds, and Inspection time scrubs. Any input change recomputes the run and rewinds it without autoplay.

Event trace

    Computed data

    Final metrics

    Fixture model: no Gemini API, SDK or ADK runtime is called. The proposed calls are fixed, and after an error the fixture’s next turn always sends valid arguments, which a real model may not do. The local function is deliberately dynamically typed (10 + "3" concatenates to "103") to show what unvalidated arguments do. The VALIDATED mode, parallel calls, call ids and thought signatures are not modeled.

    A function call is a proposal

    With function calling, the application sends function declarations with the prompt, and the model may answer with a functionCall: a name and a JSON object of arguments. Nothing runs until the application dispatches it. Here the declaration is get_forecast(city: string, required; days: integer 1 to 7, required; unit: celsius or fahrenheit, optional). The user asks whether Pune will be warmer than 25 degrees over the next 3 days. Function call proposed by the model picks one of seven fixed calls; the other inputs are the application’s own choices.

    The opening run: a plausible wrong answer

    The proposed call is get_forecast with city Pune, days 3 and unit "kelvin", and Argument validation before dispatch is None. The local function receives "kelvin", which it does not recognise, so it falls back to Celsius values and returns 24, 26 and 25 labelled as kelvin. Nothing crashes and no error is returned; the agent would present wrong units to the user. Choose Strict and the same call is rejected before execution: the error goes back to the model as a function response, the fixture’s next turn sends unit "celsius", and the forecast is correct after 2 calls and 1 returned error.

    Each malformed call, with and without checks

    Without validation, days "3" makes the dynamically typed function compute 10 + "3" = "103" as the last day; a missing city produces a forecast for "undefined"; days 14 returns 7 values for a 14-day request and a last day of 24. An undeclared argument tenant is harmless here and simply ignored. With Coerce, "3" becomes 3 and the extra argument is dropped, so both succeed in one call, while kelvin, the missing city and 14 days are still rejected. Strict also rejects the harmless extra argument, costing one repair turn. The undeclared name get_weather is always refused by the dispatcher.

    Modes and repair turns

    Function calling mode AUTO lets the model choose between a call and text; the fixture calls. NONE forbids calls even though declarations are present, so the answer is text with no forecast data. ANY forces a function call, and Allowed function names restricts which declared functions may be called; with ANY, the allowed list and the get_weather call, the call is constrained to get_forecast and runs in one turn. The allowed list has no effect outside ANY in this fixture. Repair turns after an error only matter once a validator rejects something: with Strict and 0 repair turns the kelvin call ends rejected, an explicit failure rather than a wrong answer.

    Reading the run and its limits

    Play replays the declaration, the prompt, each model turn, validation, execution and the outcome over sixty inspection seconds; Next event, Restart, Speed and Inspection time control the replay, and any input change recomputes it. The table lists the arguments that actually reached the function. The model is a fixed script, not Gemini: real models choose arguments probabilistically and may repeat a bad call after an error. The VALIDATED mode, parallel function calls, call ids, streaming and thought signatures are described in the linked articles but not modeled here.

    Views are my own and do not represent any employer, past or present.

    Search