Moving a Gemini tool loop from Google’s Interactions examples to CometAPI’s native Gemini endpoint is not just a change of URL. The adapter must change how it collects calls and serializes their results.
In Google’s parallel function-calling example, the application iterates interaction.steps and selects function_call steps. A preceding history example uses function_result with name and call_id. Those are Interactions representations—not native Gemini functionResponse parts. The parallel example shows requested calls, not a completed concurrent tool run or a multi-call result fan-in.
For the destination, CometAPI’s generating-content contract supplies the relevant requirements: preserve the preceding model content, return a corresponding functionResponse for every functionCall, match the name and returned id, and retain opaque thoughtSignature data when present.
The adapter decision: keep tool execution separate from the CometAPI serializer, and collect the complete result set before continuing the model turn. That is a design recommendation derived from the two documented representations, not a claim that CometAPI runs tools for you.
A practical implementation boundary is:
- Capture the whole call set. On the CometAPI native path, retain the preceding model content intact and collect every returned
functionCall, including its name, arguments, and id when returned. Do not rebuild the model content from just the fields your runner understands; that risks losing opaque signatures. - Run only authorized tools. Apply the application’s own permission checks before dispatch. A model request is not an authorization grant. Choose sequential or concurrent execution in the runner; the presence of several calls does not establish how they execute.
- Correlate before serializing. Associate each outcome with its originating call rather than with its position in the completion queue. Build native
functionResponseparts using the matching name and returned id. Keep any Interactionscall_idmetadata distinct from the destination’s field representation rather than copying step objects into nativeparts. - Check completeness, then continue. As an application-side guard, require one corresponding response per returned call. Stop the continuation if a result is missing or cannot be matched. Define failed-tool handling explicitly rather than silently dropping that call or reporting success. Send the preserved model content and native result parts through CometAPI only after the mapping is complete.
For an adapter test, use two calls whose tools finish in reverse order. The proposed pass condition is that both responses still match their originating calls and the preserved model content remains unchanged. A second fixture can omit one result: the local completeness guard should refuse to submit that partial turn. These are suggested tests, not reported execution results or claims about gateway rejection behavior.
The important distinction is multiple requested calls versus a valid native continuation. Google’s example helps identify the former; CometAPI’s contract determines the latter. Removing the CometAPI serialization step would leave a tool runner, but not the adapter needed for this migration. This advice is specific to the documented Gemini representations; it does not establish another model’s support, call ordering, tool-mode equivalence, or automatic concurrent execution.