MemOS
MemOS copied to clipboard
fix(suggestion_handler): split system+user so non-OpenAI LLMs accept the request
Fixes #1527.
Problem
handle_get_suggestion_queries builds a single system message:
message_list = [{"role": "system", "content": suggestion_prompt.format(memories=memories)}]
OpenAI accepts this. MiniMax (both Text API and Anthropic-compatible API) and Anthropic itself reject it with HTTP 400 (chat content is empty (2013) / messages must not be empty (2013)). Per MiniMax's own minimal example in the docs, every request must contain at least one user turn.
Change
Split into a short system persona + user message:
message_list = [
{"role": "system",
"content": "You generate suggestion queries based on the user's recent memories."},
{"role": "user",
"content": suggestion_prompt.format(memories=memories)},
]
This is a strict widening:
- OpenAI: still accepted
- MiniMax (Text + Anthropic-compat): now accepted
- Anthropic native: now accepted
No behaviour change for existing OpenAI deployments.
Type
- [x] Bug fix (non-breaking change which fixes an issue)
Tested
POST /product/suggestionswithMOS_CHAT_MODEL=MiniMax-M2.7,OPENAI_API_BASE=https://api.minimax.io/v1:- Before: 500 (or 'NoneType has no attribute replace' if running without #1524).
- After: 200 with
{\"data\":{\"query\":[\"...\",\"...\",\"...\"]}}populated by MiniMax-M2.7.
- Verified the same fix path works end-to-end (LLM call → JSON parse → SuggestionResponse).
Checklist
- [x] Self-review
- [x] Comment added at the message-list construction explaining why both roles are needed
- [ ] Unit test (would need an LLM mock; happy to add if maintainers want one)
- [x] Linked to issue
- [ ] Docs update — should we mention this in any provider-compatibility table? Could open a follow-up doc PR.