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

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

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

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

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

2026年10月5日 から。

評価

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

説明

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

主要言語
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 を短くまとめたダイジェスト。