Documentation / @agentick/google / toGoogleMessages
Function: toGoogleMessages()
toGoogleMessages(
messages):object
Defined in: google.ts:518
Transform agentick Message[] into the shape Google's GenAI API expects:
contents— the conversational turns (user / model)systemInstruction— a single string with ALL system messages joined
Google's systemInstruction accepts only one value, but agentick callers can emit multiple role: "system" messages (e.g. an identity block and a separate resource-listing block). A naïve last-write-wins implementation silently drops everything but the final system message — a class of bug that mostly surfaces in production once the system prompt is split. We accumulate ALL system message texts into systemParts and concatenate them with a blank-line separator, mirroring the Anthropic adapter's toAnthropicMessages pattern.
Empty system messages (no text blocks, or all empty after filtering) are skipped so they don't introduce spurious separators.
Parameters
messages
Message[]
Returns
object
contents
contents:
any[]
systemInstruction
systemInstruction:
string|undefined