Streaming API returns empty role string in delta chunks, breaking OpenAI-compatible clients

Aberta
#2 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Domínio
api

Direção de pesquisa

The report concerns streaming responses from https://api.minimax.io/v1/chat/completions, but names no repository files or tests, so begin by locating the streaming chat completion response implementation. Check how delta role fields are produced and whether a streaming response test covers empty roles. Done means empty role values are omitted or validly set to assistant, with a test confirming the response.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Problem

When using the MiniMax M2.5 streaming chat completion API (https://api.minimax.io/v1/chat/completions with stream: true), some chunks contain "role": "" (empty string) in the delta object. This breaks OpenAI-compatible SDK clients that validate role against the expected value "assistant".

Expected behavior

Per the OpenAI streaming spec, the role field in delta objects should either be "assistant" (typically in the first chunk) or omitted entirely in subsequent chunks. An empty string "" is neither.

Actual behavior

MiniMax returns chunks like:

{
  "choices": [{
    "index": 0,
    "delta": {
      "role": "",
      "reasoning_content": ""
    }
  }],
  "created": 1771279826,
  "object": "chat.completion.chunk",
  "usage": {"total_tokens": 0, "total_characters": 0},
  "input_sensitive": false,
  "output_sensitive": false
}

The "role": "" fails validation in clients that expect "assistant" as the only valid value (e.g., Vercel AI SDK's @ai-sdk/openai-compatible).

Error from client

AI_TypeValidationError: Type validation failed
Invalid input: expected "assistant" at choices[0].delta.role

Suggested fix

Either:

  1. Set role: "assistant" in the first delta chunk and omit it from subsequent chunks (matching OpenAI behavior)
  2. Or omit the role field entirely when it would be empty

Environment

  • API endpoint: https://api.minimax.io/v1/chat/completions
  • Model: MiniMax-M2.5
  • Streaming: enabled
  • Client: @ai-sdk/openai-compatible (Vercel AI SDK) via OpenCode
Linguagem predominante
Sem dados de linguagem
Estrelas
588
Forks
83
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de MiniMax-AI/MiniMax-M2.5

Todas as issues de MiniMax-AI/MiniMax-M2.5

Issues semelhantes

Mais issues de Backend & API Design

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.