-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
Models
magistral-medium-2509
magistral-medium-latest
magistral-small-2509
magistral-small-latest
Request Payload
import asyncio
import os
from mistralai import Mistral
TOOL = {
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string", "description": "City name"}},
"required": ["city"],
},
},
}
async def main():
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
for model in [
"magistral-medium-2509",
"magistral-medium-latest",
"magistral-small-2509",
"magistral-small-latest",
]:
resp = await client.chat.complete_async(
model=model,
messages=[{"role": "user", "content": "Say hello."}],
tools=[TOOL],
tool_choice="required",
max_tokens=256,
temperature=0,
)
choice = resp.choices[0]
print(f"{model}: finish_reason={choice.finish_reason}, tool_calls={choice.message.tool_calls}")
asyncio.run(main())Output
All four magistral models return a text response with no tool calls, despite tool_choice="required":
magistral-medium-2509: finish_reason=length, tool_calls=None
magistral-medium-latest: finish_reason=length, tool_calls=None
magistral-small-2509: finish_reason=length, tool_calls=None
magistral-small-latest: finish_reason=length, tool_calls=None
The response content is a plain text greeting (e.g. "Hello! How can I assist you today?") with no tool invocation.
Expected Behavior
When tool_choice="required" is set, the model should always produce at least one tool call, regardless of the prompt content. This is the documented behavior and works correctly with other Mistral model families (e.g. mistral-large-latest, mistral-small-latest, codestral-latest).
Additional Context
No response
Suggested Solutions
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels