Problem When using ollamaChatModel.call(), the "thinking" metadata field is correctly returned. However, when using the streaming API (ollamaChatModel.stream()), the "thinking" field always comes as null.
Code Snippet Non-streaming version (works):
ChatResponse response = ollamaChatModel.call(...);
String thinking = response.getResult().getMetadata().get("thinking"); // Works
Streaming version (not working):
Flux<ChatResponse> stream = ollamaChatModel.stream(
new Prompt(
"Hi",
OllamaChatOptions.builder()
.model("gpt-oss:20b")
.enableThinking()
.thinkHigh()
.build()
)
);
stream.subscribe(response -> {
String thinking = response.getResult().getMetadata().get("thinking"); //always null
String content = response.getResult().getOutput().getText();
System.out.println("[Thinking] " + thinking); //it's null
System.out.println("[Response] " + content);
});
The thinking field is coming as null.
If I’m missing something or need to enable any additional setting for streaming to return the thinking data, please let me know.
From what I can see, in the non-streaming path
internalCall()
the "thinking" metadata is being extracted and added to the response.
But in the streaming path
internalStream()
that logic seems to be missing, so the thinking field may not be populated.
I’m not sure if this is handled elsewhere — just guessing here. If its working for others, please let me know.
Comment From: arlaneenalra
I just ran into this and spent an hour or so thinking that ChatClient was stripping the thinking metadata out of it's responses. Nope, it's not getting added in the first place and lines pretty much exactly with what @sharan245 is stating.