今日已更新 166 条资讯 | 累计 40611 条内容
关于我们

Gemini Function Calling Is Not an Agent Runtime

Raju Dandigam 2026年08月31日 14:26 1 次阅读 来源:Dev.to

Gemini function calling makes tool use look simple. You describe a function, provide its input schema, and let the model decide whether the user's request requires it. A traveler asks, "Find hotels in Paris under $250," Gemini requests search_hotels , your application executes it, and the model turns the result into a useful answer. That is an important capability, but it is not an agent runtime. Function calling tells your application what the model proposes to do. It does not decide whether the action is authorized, whether the arguments are trustworthy, whether the same action already succeeded, or whether a retry would make the situation worse. The model proposes. The runtime disposes. What Gemini actually gives you With the Google Gen AI SDK, a function declaration can look like this: import { GoogleGenAI , Type } from " @google/genai " ; const ai = new GoogleGenAI ({ apiKey : process . env . GEMINI_API_KEY , }); const searchHotels = { name : " search_hotels " , description : " Search available hotels in a city under an optional nightly price " , parameters : { type : Type . OBJECT , properties : { city : { type : Type . STRING , description : " City and country, for example Paris, France " , }, maxNightlyPriceUsd : { type : Type . NUMBER , description : " Maximum nightly price in US dollars " , }, }, required : [ " city " ], }, }; const response = await ai . models . generateContent ({ model : " gemini-2.5-flash " , contents : " Find hotels in Paris under $250 per night " , config : { tools : [{ functionDeclarations : [ searchHotels ] }], }, }); const proposedCall = response . functionCalls ?.[ 0 ]; The returned function call contains a name and structured arguments. Google is explicit about the next boundary: the model does not execute your business function. Your application is responsible for executing it and returning the result. That boundary is where production engineering begins. User request │ ▼ Gemini proposes a function call │ ▼ Schema validation → a

本文内容来源于互联网,版权归原作者所有
查看原文