@ai-sdk/google 3.0.130 → 3.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,4 +79,22 @@ export interface GoogleGenerativeAIProviderMetadata {
79
79
  usageMetadata: GoogleGenerativeAIUsageMetadata | null;
80
80
  finishMessage: string | null;
81
81
  serviceTier: string | null;
82
+
83
+ /**
84
+ * Opaque token returned when a response stops with `MAX_TOKENS` because it
85
+ * used up its `maxOutputTokens` budget. Pass it back as
86
+ * `providerOptions.google.continuationToken` together with a higher
87
+ * `maxOutputTokens` and the original prompt to resume generation.
88
+ */
89
+ continuationToken?: string | null;
90
+
91
+ /**
92
+ * Prompt token count of the first request of a long decode response that
93
+ * was continued automatically (Gemini 4). Usage is summed across requests
94
+ * to match billing, and each continued request re-sends the prompt plus all
95
+ * output so far as input. Use this value instead of the summed input tokens
96
+ * for context window checks and compaction. Only present when the response
97
+ * spanned more than one request.
98
+ */
99
+ initialPromptTokenCount?: number | null;
82
100
  }
@@ -37,6 +37,8 @@ export type GoogleInteractionsModelId =
37
37
  | 'gemini-3.6-flash'
38
38
  | 'gemini-3.7-flash'
39
39
  | 'gemini-3.8-flash'
40
+ | 'gemini-4-argon'
41
+ | 'gemini-nano-banana-2.1'
40
42
  | 'lyria-3-clip-preview'
41
43
  | 'lyria-3-pro-preview'
42
44
  | (string & {});
@@ -454,7 +454,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
454
454
  async doGenerate(
455
455
  options: LanguageModelV3CallOptions,
456
456
  ): Promise<LanguageModelV3GenerateResult> {
457
- const { args, warnings, isAgent, pollingTimeoutMs } =
457
+ const { args, warnings, isAgent, isBackground, pollingTimeoutMs } =
458
458
  await this.getArgs(options);
459
459
 
460
460
  const url = `${this.config.baseURL}/interactions`;
@@ -484,12 +484,12 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
484
484
  } = postResult;
485
485
 
486
486
  /*
487
- * Agent calls may return a non-terminal status (`in_progress` /
488
- * `requires_action`) when invoked with `background: true`. Poll
489
- * `GET /interactions/{id}` until terminal so the user-facing surface
490
- * matches a synchronous call.
487
+ * Agent calls and `background: true` calls (e.g. Gemini 4 long decode,
488
+ * where the server runs every hop) may return a non-terminal status
489
+ * (`in_progress` / `requires_action`). Poll `GET /interactions/{id}` until
490
+ * terminal so the user-facing surface matches a synchronous call.
491
491
  */
492
- if (isAgent && !isTerminalStatus(response.status)) {
492
+ if ((isAgent || isBackground) && !isTerminalStatus(response.status)) {
493
493
  const polled = await pollGoogleInteractionUntilTerminal({
494
494
  baseURL: this.config.baseURL,
495
495
  interactionId: response.id,
@@ -11,6 +11,9 @@ export function mapGoogleGenerativeAIFinishReason({
11
11
  case 'STOP':
12
12
  return hasToolCalls ? 'tool-calls' : 'stop';
13
13
  case 'MAX_TOKENS':
14
+ // Gemini 4 long decode: the per-request cap was reached while budget
15
+ // remains. Continued automatically; only surfaced if continuing fails.
16
+ case 'CONTINUATION':
14
17
  return 'length';
15
18
  case 'IMAGE_SAFETY':
16
19
  case 'RECITATION':