Skip to content

Ollama Streaming API does not return 'thinking' metadata in ChatResponse #4866

@sharan245

Description

@sharan245

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions