Bug report - Getting error response with deepseek r1
Aider version: 0.72.1 Python version: 3.12.8 Platform: macOS-15.2-arm64-arm-64bit Python implementation: CPython Virtual environment: Yes OS: Darwin 24.2.0 (64bit) Git version: git version 2.39.5 (Apple Git-154)
Aider v0.72.1 Main model: deepseek/deepseek-reasoner with ask edit format, prompt cache, infinite output Weak model: deepseek/deepseek-chat Git repo: .git with 10 files Repo-map: using 4000.0 tokens, auto refresh Added Cargo.toml to the chat. Added src/lib.rs to the chat. Added src/libs/mod.rs to the chat. Added src/libs/parser.rs to the chat. Added src/libs/peekable_deque.rs to the chat. Added src/main.rs to the chat. Added tests/parser_test.rs to the chat.
Here is the error I get:
litellm.BadRequestError: DeepseekException - Error code: 400 - {'error': {'message':
'deepseek-reasoner does not support successive user or assistant messages (messages[5] and
messages[6] in your input). You should interleave the user/assistant messages in the
message sequence.', 'type': 'invalid_request_error', 'param': None, 'code':
'invalid_request_error'}}
I tried in both /ask and /code mode. Other models work fine. R1 works fine with same API key I use for aider with simple curl command:
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <DeepSeek API Key>" \
-d '{
"model": "deepseek-reasoner",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": false
}'
I use the same API key in aider for deepseek-coder without issues.
Duplicate of #2925.