spring-projects / spring-projects/spring-ai

DefaultChatClient returns null content when using Bedrock Converse API with openai.gpt-oss models

Open
#4,522 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bedrock bug
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description
When using Spring AI with Bedrock Converse API and the models like 'openai.gpt-oss-20b-1:0', 'openai.gpt-oss-120b-1:0', the DefaultChatClient does not correctly extract the assistant response.

The model returns multiple Generation objects in the ChatResponse:

  • The first Generation has textContent = null and finishReason = end_turn. (Originally, it was reasoning output from the BedrockClient, but it misses textContent)
  • The second Generation contains the actual assistant message finishReason = end_turn and textContent = "Hello! How can I help you today?".

However, DefaultCallResponseSpec.content() and DefaultCallResponseSpec.entity() only take the textContent from the first generation, which leads to null being returned instead of the real model output.

Environment
Bedrock Converse API + openai.gpt-oss-20b-1:0 or openai.gpt-oss-120b-1:0

Steps to reproduce

var content = chatClientRegistry
    .get(getType())
    .prompt("Hello")
    .call()
    .content();

System.out.println(content); // returns null

Inspecting chatResponse() shows two generations:

  • Generation[0]: textContent = null, finishReason = end_turn
  • Generation[1]: textContent = "Hello! How can I help you today?", finishReason = end_turn

Expected behavior
While using Bedrock Converse API + openai.gpt-oss-20b-1:0 content() method can return actual model output instead of null.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating DefaultCallResponseSpec.content() and entity(), then inspect how they read the first Generation from ChatResponse. Reproduce the issue with the Bedrock Converse API and an openai.gpt-oss model, checking both generations. Done means content() and entity() return the actual assistant message rather than null when the first generation has no textContent.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java, spring
Domain
ai, backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.