Anthropic reasoning model's work correctly when the last message in the messages list is a user message. However, this is not always the case. When working with agents that make tool calls, the user message will be followed by an assistant + tool(s) messages. When the last message is not a user message, the model doesn't use reasoning: It is like the reasoning_effort parameter gets ignored in this situation.
Anthropic models are arguably the best agentic models out there, and this bug degrades the performance of agentic workflows when using the models through OpenRouter. Hopefully this issue can get resolved quickly.
Sample code to replicate the issue is provided below. When using the OpenAI and Gemini models, the result will contain non empty reasoning and reasoning_details fields. When running the same code with Anthropic, no reasoning occurs. If you comment out the second message in the messages list, then all models, including the ones from Anthropic, will work as expected. I have also tested generations where the last message is a tool message, which occurs in our agentic workflows. I get the exact same issue with Anthropic models..
import requests
def call_openrouter(prompt, model="anthropic/claude-sonnet-4.5"):
url = "https://openrouter.ai/api/v1/chat/completions"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {"model": model, "reasoning_effort": "low",
"messages": [
{"role": "user", "content": prompt},
{"role": "assistant", "content": "Answer: "} #When this is commented out, the model will reason.
]
}
response = requests.post(url, headers=headers, json=data,)
return response.json()
result = call_openrouter("What is the capital of France?")
result
Generation ID with reasoning not used: gen-1759271728-NJH6ykZRLXsf13bRBbLC
Generation ID that worked correctly: gen-1759271739-1dT1TRggPAFLDU05fSA0
@acoustic imp