From 4191bf287c61b13d4df1b709bdbec59666798891 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 3 Aug 2026 10:33:11 -0400 Subject: [PATCH] test(mistralai): use deliberation-inducing prompt in reasoning tests The scheduled integration runs have failed on `test_reasoning` and `test_reasoning_v1` since July 31: `magistral-medium-latest` no longer emits thinking/reasoning blocks for the trivial greeting prompt these tests used ("Hello, my name is Bob"), so the `assert blocks > 0` check failed on every retry across both Python versions. Switch both tests to a math word problem, which reliably triggers deliberation, and adjust the follow-up turn accordingly. --- .../tests/integration_tests/test_chat_models.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/partners/mistralai/tests/integration_tests/test_chat_models.py b/libs/partners/mistralai/tests/integration_tests/test_chat_models.py index 4ca23b5aeb..bb02e9bb29 100644 --- a/libs/partners/mistralai/tests/integration_tests/test_chat_models.py +++ b/libs/partners/mistralai/tests/integration_tests/test_chat_models.py @@ -153,7 +153,12 @@ def test_reasoning() -> None: model = ChatMistralAI(model="magistral-medium-latest", rate_limiter=rate_limiter) # type: ignore[call-arg] input_message = { "role": "user", - "content": "Hello, my name is Bob.", + # Mistral only returns reasoning blocks when the model judges the prompt + # to need deliberation. A math word problem triggers this reliably; the + # previous trivial greeting ("Hello, my name is Bob") stopped producing + # any thinking content provider-side in July 2026. + "content": "A train travels 120 km in 1.5 hours, then 80 km in 45 minutes. " + "What is its average speed for the whole journey, in km/h?", } full: AIMessageChunk | None = None for chunk in model.stream([input_message]): @@ -169,7 +174,9 @@ def test_reasoning() -> None: assert isinstance(reasoning_block.get("reasoning"), str) assert thinking_blocks > 0 - next_message = {"role": "user", "content": "What is my name?"} + # Verify a prior assistant message carrying thinking blocks can be sent + # back in multi-turn conversation. + next_message = {"role": "user", "content": "What was your final answer?"} _ = model.invoke([input_message, full, next_message]) @@ -181,7 +188,9 @@ def test_reasoning_v1() -> None: ) input_message = { "role": "user", - "content": "Hello, my name is Bob.", + # See test_reasoning for why this prompt needs to demand deliberation. + "content": "A train travels 120 km in 1.5 hours, then 80 km in 45 minutes. " + "What is its average speed for the whole journey, in km/h?", } full: AIMessageChunk | None = None chunks = [] @@ -197,7 +206,7 @@ def test_reasoning_v1() -> None: assert isinstance(block.get("reasoning"), str) assert reasoning_blocks > 0 - next_message = {"role": "user", "content": "What is my name?"} + next_message = {"role": "user", "content": "What was your final answer?"} _ = model.invoke([input_message, full, next_message])