Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)

Abierto
#1,280 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@hemasekhar-p ya está trabajando en esto.

Desde el 5/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

priority: p2 type: bug
Environment details
  • SDK version: com.google.genai:google-genai:1.73.0 (also reproducible on main)
  • Java version: 21 / 25
Problem description

com.google.genai.gaos.models.interactions.Interaction.outputText() is documented as an SDK-populated convenience property:

    /**
     * Concatenated text from the last model output in response to the current request.
     *
     * <p>Note: this is added by the SDK.
     */
    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("output_text")
    private String outputText;

(Interaction.java#L176-L183)

However, the Gemini Interactions REST API does not return an "output_text" field in the JSON response payload (text blocks are returned inside steps -> ModelOutputStep -> TextContent). Because Interaction.java is generated by Speakeasy as a plain Jackson POJO and no SDK hook or getter computes outputText from steps, interaction.outputText() always returns Optional.empty().

(The same appears to apply to outputAudio(), outputImage(), and outputVideo() on Interaction.)

Steps to reproduce
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

public class Repro {
  public static void main(String[] args) {
    try (Client client = new Client()) {
      CreateModelInteraction request =
          CreateModelInteraction.builder()
              .model("gemini-2.5-flash")
              .input(InteractionsInput.of("Tell me a short joke."))
              .build();

      Interaction interaction =
          client.interactions
              .create(CreateInteractionRequestBody.of(request))
              .interaction()
              .orElseThrow();

      // Prints Optional.empty even though interaction.steps() contains a ModelOutputStep with TextContent
      System.out.println("outputText: " + interaction.outputText());
    }
  }
}
Current workaround

Callers have to manually traverse interaction.steps(), unwrap Step.value(), match ModelOutputStep, iterate its content(), unwrap Content.value(), and concatenate TextContent.text():

StringBuilder sb = new StringBuilder();
interaction.steps().ifPresent(steps -> {
  for (var step : steps) {
    if (step.value() instanceof ModelOutputStep modelOutput) {
      modelOutput.content().ifPresent(contents -> {
        for (var content : contents) {
          if (content.value() instanceof TextContent textContent) {
            textContent.text().ifPresent(sb::append);
          }
        }
      });
    }
  }
});
Expected behavior

interaction.outputText() should return the concatenated text from the last ModelOutputStep in interaction.steps() (either computed lazily in Interaction.outputText() when this.outputText == null, or populated via a Speakeasy AfterSuccess hook in SDKHooks), matching the Javadoc contract ("Concatenated text from the last model output in response to the current request. Note: this is added by the SDK.").

Lenguaje dominante
Java
Estrellas
398
Forks
126
Merge medio
1 d 12 h
PR fusionados (30 d)
71

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de googleapis/java-genai

Todos los issues de googleapis/java-genai

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.