Fix OllamaChatModel dropping thinking field in multi-turn conversation history
Closes #6016 (Ollama path).
Problem
OllamaChatModel stores the thinking field from model responses in
ChatGenerationMetadata (via builder.metadata("thinking", thinking)),
but when an AssistantMessage is replayed as conversation history in a
follow-up request, only AssistantMessage.properties is accessible —
ChatGenerationMetadata is not available at that point. As a result,
thinking was always null when building the outbound OllamaApi.Message,
silently breaking multi-turn conversations with Qwen3 and other thinking models.
Fix
Extract thinking from the Ollama response at both receive sites (blocking
and streaming) and store it in AssistantMessage.properties under the same
"thinking" key, in addition to the existing ChatGenerationMetadata storage.
The createRequest() ASSISTANT branch already reads that key from
AssistantMessage.getMetadata() and passes it to Message.Builder.thinking().
Test plan
- [ ] Unit test: build an
AssistantMessagewiththinkingin properties, callollamaChatRequest(), verify the outboundOllamaApi.Messagecarriesthinking - [ ] Existing
OllamaChatModelTestspass - [ ] Streaming path: same round-trip test using the streaming code path
The failing CI check ('MCP common and annotations integration tests') is caused by a known flaky test: WebClientStreamableHttpTransportErrorHandlingIT.testSessionRecoveryAfter404 (race condition, tracked in #5563). This failure is unrelated to the Ollama changes in this PR, which only touch OllamaChatModel.java and its test. The 'Build branch' check passes cleanly.