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

Đang mở
#1,280 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hemasekhar-p đang làm issue này rồi.

Từ ngày 5/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.").

Ngôn ngữ chính
Java
Star
398
Fork
126
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
71

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleapis/java-genai

Tất cả issue của googleapis/java-genai

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.