Skip to content

[Bug] suggestion_handler sends system-only message — fails on MiniMax & Anthropic LLMs #1527

@Ptah-CT

Description

@Ptah-CT

Summary

handle_get_suggestion_queries in src/memos/api/handlers/suggestion_handler.py builds the LLM request as a single system message:

message_list = [{"role": "system", "content": suggestion_prompt.format(memories=memories)}]
response = llm.generate(message_list)

OpenAI accepts this shape. Several other LLM backends do not, including the ones MemOS already documents/configures (minimax, plus Anthropic-compatible endpoints like the MiniMax Anthropic gateway):

Backend Endpoint Response
MiniMax Text API https://api.minimax.io/v1/chat/completions HTTP 400 invalid params, chat content is empty (2013)
MiniMax Anthropic-compat https://api.minimax.io/anthropic/v1/messages HTTP 400 invalid params, messages must not be empty (2013)
Anthropic native https://api.anthropic.com/v1/messages (same — system is a top-level field, messages[] must have ≥1 user turn)

Per MiniMax's own minimal example in the official docs, even system-only is rejected:

{
  "model": "MiniMax-M2.7",
  "messages": [
    { "role": "system", "name": "MiniMax AI" },
    { "role": "user",   "name": "user", "content": "hello" }
  ]
}

Reproduction

  1. MOS_CHAT_MODEL=MiniMax-M2.7, OPENAI_API_BASE=https://api.minimax.io/v1, valid OPENAI_API_KEY.
  2. POST /product/suggestions with mem_cube_id=<existing cube>, language=en.
  3. Server returns HTTP 500. With [Bug] timed_with_status decorator silently swallows exceptions and returns None #1523 fixed: openai.BadRequestError: Error code: 400 ... 'chat content is empty (2013)'. Without: AttributeError: 'NoneType' object has no attribute 'replace'.

Proposed fix

Split the prompt into a short system persona and a user message containing the actual instruction. OpenAI accepts this; MiniMax/Anthropic require it.

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 — every backend that accepts the original system-only shape also accepts the split shape. No behaviour change for existing OpenAI/Azure deployments.

PR follows.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions