Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserialization

オープン
#1,281 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@hemasekhar-p がすでに取り組んでいます。

2026年10月5日 から。

評価

この issue はまだ評価されていません。

説明

priority: p2 type: bug
Environment
  • com.google.genai:google-genai:1.73.0
  • Java 21+
Problem Description

When creating a stateless interaction with .store(false) on CreateModelInteraction, the Gemini Interactions API server does not persist the interaction and therefore omits the "id" field from the "interaction" JSON object in responses and SSE events (and omits "interaction_id" in interaction.status_update SSE events).

For example, the server sends the following SSE payload at the end of a store(false) stream:

{
  "interaction": {
    "status": "completed",
    "usage": {
      "input_tokens_by_modality": [{"modality": "text", "tokens": 19}],
      "total_input_tokens": 19,
      "total_output_tokens": 4,
      "total_thought_tokens": 0,
      "total_tokens": 23
    },
    "created": "2026-10-04T19:11:19Z",
    "updated": "2026-10-04T19:11:19Z",
    "service_tier": "standard",
    "object": "interaction",
    "model": "gemini-3.1-flash-lite-preview"
  },
  "event_type": "interaction.completed"
}

However, in com.google.genai.gaos.models.interactions, the id / interactionId fields are generated as @Nonnull String and enforce non-nullability in their @JsonCreator constructors:

  • InteractionSseEventInteraction.<init> (InteractionSseEventInteraction.java:123):
    this.id = Optional.ofNullable(id)
        .orElseThrow(() -> new IllegalArgumentException("id cannot be null"));
    
  • InteractionStatusUpdate.<init>: throws IllegalArgumentException("interactionId cannot be null")
  • Interaction.<init>: throws IllegalArgumentException("id cannot be null")

Because "id" is absent when store(false) is used:

  1. In streaming mode (stream(true) + store(false)): InteractionSseEventInteraction.<init> throws IllegalArgumentException: id cannot be null during Jackson deserialization. The SSE union deserializer catches the failure and silently falls back to UnknownInteractionSSEEvent (with eventType() == "UNKNOWN" and asJson() containing a TextNode of the raw JSON string) for interaction.created, interaction.status_update, and interaction.completed. As a result, callers matching InteractionCompletedEvent never receive the completion event or Usage token counts.
  2. In non-streaming mode (stream(false) + store(false)): Interaction.<init> fails with ValueInstantiationException: Cannot construct instance of com.google.genai.gaos.models.interactions.Interaction, problem: id cannot be null.
Steps to Reproduce
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.InteractionCompletedEvent;
import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.UnknownInteractionSSEEvent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

public class Repro {
  public static void main(String[] args) throws Exception {
    Client client = Client.builder().build();

    var request =
        CreateModelInteraction.builder()
            .model(Model.GEMINI_3_1_FLASH_LITE_PREVIEW)
            .input(InteractionsInput.of("Say hello in one word."))
            .store(false)
            .stream(true)
            .build();

    try (var events =
        client.interactions.create(CreateInteractionRequestBody.of(request)).events()) {
      for (InteractionSSEStreamEvent streamEvent : events) {
        InteractionSSEEvent event = streamEvent.data().orElseThrow();
        if (event instanceof InteractionCompletedEvent completed) {
          System.out.println("Completed usage: " + completed.interaction().get().usage());
        } else if (event instanceof UnknownInteractionSSEEvent unknown) {
          System.out.println("Fell back to UnknownInteractionSSEEvent: " + unknown.asJson());
        }
      }
    }
  }
}
Expected Behavior

Interaction.id, InteractionSseEventInteraction.id, and InteractionStatusUpdate.interactionId should be optional/nullable (Optional<String>) in the OpenAPI specification and generated SDK classes so that store(false) responses and InteractionCompletedEvent SSE events deserialize properly.

主要言語
Java
スター
398
フォーク
126
平均マージ
1日 12時間
マージ済み PR(30日)
71

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/java-genai のほかの issue

googleapis/java-genai の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。