Skip to content
1 min read · 161 words

Function: buildGeminiRequest()

ts
function buildGeminiRequest(
  input: GeminiRequestBuildInput,
): Promise<GeminiGenerateContentRequest>;

Defined in: src/batteries/llm/gemini_generate_content/helpers.ts:257

Assemble the native request from ADK turn state. THE ordering seam.

Parameters

ParameterType
inputGeminiRequestBuildInput

Returns

Promise<GeminiGenerateContentRequest>

Remarks

The translation that makes this battery different from pointing openai_chat_completions at a Gemini gateway:

  • System text goes to systemInstruction, not a contents[] turn.
  • Message.role: 'assistant' becomes role: 'model'.
  • A ToolCall becomes TWO turns: a model turn with a functionCall part, then a user turn with a functionResponse part. functionResponse.name carries the DECLARED tool name, because Gemini has no call-id correlation.
  • Timeline order is createdAt, matching the ordering guard's own view, so what the guard validates is what gets dispatched.
  • The thought-signature sentinel is stamped on the FIRST functionCall only when no part already carries a real signature and the caller has not opted out. Preserving a genuine signature matters: it is prefix-bound, and replacing one invalidates it.