Skip to content

fix(suggestion_handler): split system+user so non-OpenAI LLMs accept the request#1528

Open
Ptah-CT wants to merge 1 commit intoMemTensor:mainfrom
Ptah-CT:fix/suggestion-handler-system-only-fails-minimax
Open

fix(suggestion_handler): split system+user so non-OpenAI LLMs accept the request#1528
Ptah-CT wants to merge 1 commit intoMemTensor:mainfrom
Ptah-CT:fix/suggestion-handler-system-only-fails-minimax

Conversation

@Ptah-CT
Copy link
Copy Markdown

@Ptah-CT Ptah-CT commented Apr 22, 2026

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

  • Bug fix (non-breaking change which fixes an issue)

Tested

  • POST /product/suggestions with MOS_CHAT_MODEL=MiniMax-M2.7, OPENAI_API_BASE=https://api.minimax.io/v1:
  • Verified the same fix path works end-to-end (LLM call → JSON parse → SuggestionResponse).

Checklist

  • Self-review
  • 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)
  • Linked to issue
  • Docs update — should we mention this in any provider-compatibility table? Could open a follow-up doc PR.

…the request

handle_get_suggestion_queries built a message list with a single system
role. OpenAI accepts that shape; several other LLM backends do not:

- MiniMax (Text API at https://api.minimax.io/v1/chat/completions)
  rejects with HTTP 400 'invalid params, chat content is empty (2013)'.
- MiniMax Anthropic-compatible API (https://api.minimax.io/anthropic/v1/messages)
  rejects with HTTP 400 'invalid params, messages must not be empty (2013)'.
- The official Anthropic Messages API has the same requirement (system is
  a top-level field; messages[] must contain at least one user turn).

Move the suggestion prompt into a user message and keep a short system
role for the persona. OpenAI and other strict-schema providers both
accept this shape, so it is a strict widening with no behaviour change
for OpenAI/Azure deployments.

Repro of the original bug:
  POST /product/suggestions
  with MOS_CHAT_MODEL=MiniMax-M2.7,
       OPENAI_API_BASE=https://api.minimax.io/v1
  -> backend hits MiniMax which returns 400 (2013).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants