vercel/ai · error

Unsupported content type in assistant message: ${part.type}

Error message

Unsupported content type in assistant message: ${part.type}

What it means

convertToMistralChatMessages switches over assistant message part types and only supports text, tool-call, and reasoning parts. An unrecognized assistant part type falls into the default branch and throws a plain Error naming the unsupported type.

Source

Thrown at packages/mistral/src/convert-to-mistral-chat-messages.ts:143

                type: 'function',
                function: {
                  name: part.toolName,
                  arguments: JSON.stringify(part.input),
                },
              });
              break;
            }
            case 'reasoning': {
              hasReasoning = true;
              contentParts.push({
                type: 'thinking',
                thinking: [{ type: 'text', text: part.text }],
                closed: true,
              });
              break;
            }
            default: {
              throw new Error(
                `Unsupported content type in assistant message: ${part.type}`,
              );
            }
          }
        }

        messages.push({
          role: 'assistant',
          content: hasReasoning ? contentParts : text,
          prefix: isLastMessage ? true : undefined,
          tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
        });

        break;
      }
      case 'tool': {
        for (const toolResponse of content) {
          if (toolResponse.type === 'tool-approval-response') {

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Remove or convert unsupported assistant parts before sending to Mistral.
  2. Map unsupported parts to plain text parts where content allows.
  3. Update @ai-sdk/mistral to the latest version for broader part support.
  4. Strip provider-specific parts when persisting/replaying conversation history.

Example fix

// before: assistant message with unsupported part
{ role: 'assistant', content: [{ type: 'redacted-reasoning', ... }] }
// after: keep only supported parts
{ role: 'assistant', content: [{ type: 'text', text: 'assistant reply' }] }
Defensive patterns

Strategy: type-guard

Validate before calling

const supportedAssistantTypes = new Set(['text', 'tool-call', 'reasoning']);
function hasUnsupportedAssistantParts(prompt: { messages: { role: string; content: { type: string }[] }[] }[]): boolean {
  return prompt.some(m => m.role === 'assistant' && m.content.some(p => !supportedAssistantTypes.has(p.type)));
}

Type guard

function isSupportedAssistantPart(part: { type: string }): boolean {
  return ['text', 'tool-call', 'reasoning'].includes(part.type);
}

Try / catch

try {
  await generateText({ model: mistral(modelId), prompt });
} catch (error) {
  if (error instanceof Error && error.message.startsWith('Unsupported content type in assistant message')) {
    // strip/convert the offending part type and retry
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: Passing a prompt whose assistant message contains a part type the Mistral converter doesn't handle (e.g. a newer part kind introduced in the spec but not yet mapped for Mistral) via generateText/streamText.

Common situations: Replaying multi-provider conversation histories (with provider-specific parts) against Mistral; SDK version skew where prompts contain part types added after Mistral support was written.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/0f694fbdd87004d4. Report an issue: GitHub.