Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#1,281 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hemasekhar-p ci sta già lavorando.

Dal 5/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Java
Stelle
398
Fork
126
Merge medio
1g 12h
PR unite (30g)
71

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/java-genai

Tutte le issue di googleapis/java-genai

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.