Skip to content

[Bug]: Anthropic Messages API + Mistral model: "Invalid assistant message" on multi-turn tool calling #38738

@YoyoSailer

Description

@YoyoSailer

Your current environment

The output of python collect_env.py
Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.2 LTS (x86_64)
GCC version                  : (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version                : Could not collect
CMake version                : version 3.28.3
Libc version                 : glibc-2.39

==============================
       PyTorch Info
==============================
PyTorch version              : 2.10.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.12.10 (main, Apr  1 2026, 14:48:37) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.17.0-19-generic-x86_64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 12.9.86
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : GPU 0: NVIDIA GeForce RTX 5090
Nvidia driver version        : 590.48.01
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           46 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  32
On-line CPU(s) list:                     0-20,22-31
Off-line CPU(s) list:                    21
Vendor ID:                               GenuineIntel
Model name:                              Intel(R) Core(TM) i9-14900K
CPU family:                              6
Model:                                   183
Thread(s) per core:                      2
Core(s) per socket:                      23
Socket(s):                               1
Stepping:                                1
CPU(s) scaling MHz:                      47%
CPU max MHz:                             6000.0000
CPU min MHz:                             0.0000
BogoMIPS:                                6374.40
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                          VT-x
L1d cache:                               864 KiB (23 instances)
L1i cache:                               1.2 MiB (23 instances)
L2 cache:                                32 MiB (12 instances)
L3 cache:                                36 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-20,22-31
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Mitigation; Clear Register File
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.6
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torchaudio==2.10.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.6
[pip3] triton==3.6.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.18.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
        GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      0-20,22-31      0               N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_janab

🐛 Describe the bug

Current environment

  • vLLM version: 0.18.1
  • Model: mistralai/Ministral-3-14B-Instruct-2512 (official release)
  • Served model name: ministral-3:14b
  • Also reproduced with: cyankiwi/Ministral-3-14B-Instruct-2512-AWQ-4bit (AWQ 4-bit quantized)
  • Python: 3.12.10
  • OS: Linux

Describe the bug

When using the Anthropic Messages API endpoint (/v1/messages) with a Mistral model and tool calling enabled, multi-turn conversations crash on the second turn with:

Invalid assistant message: role='assistant' content='' tool_calls=None prefix=False

The first turn works fine: model receives prompt, responds with tool calls, tools execute successfully. The error occurs when sending tool results back for the next model turn. The Anthropic adapter generates an empty assistant message internally during Anthropic-to-OpenAI format conversion that the Mistral renderer then rejects.

Server command

vllm serve mistralai/Ministral-3-14B-Instruct-2512 \
  --host 0.0.0.0 \
  --port 11434 \
  --gpu-memory-utilization 0.95 \
  --max-model-len 82000 \
  --max-num-batched-tokens 8192 \
  --tokenizer_mode auto \
  --served-model-name ministral-3:14b \
  --enable-auto-tool-choice \
  --tool-call-parser mistral \
  --config_format mistral \
  --load_format mistral

Client

Claude Code CLI pointed at vLLM via ANTHROPIC_BASE_URL=http://localhost:11434. Also reproduced via llm-party (multi-agent orchestrator using Claude SDK).

Full stack trace

File "vllm/renderers/mistral.py", line 34, in safe_apply_chat_template
    return tokenizer.apply_chat_template(messages, **kwargs)
File "vllm/tokenizers/mistral.py", line 444, in apply_chat_template
    return self.transformers_tokenizer.apply_chat_template(
File "transformers/tokenization_mistral_common.py", line 1510, in apply_chat_template
    tokenized_request = self.tokenizer.encode_chat_completion(chat_request)
File "mistral_common/tokens/tokenizers/mistral.py", line 389, in encode_chat_completion
    return self.instruct_tokenizer.encode_instruct(instruct_request)
File "mistral_common/tokens/tokenizers/instruct.py", line 200, in encode_instruct
    new_tokens = self.encode_assistant_message(
File "mistral_common/tokens/tokenizers/instruct.py", line 1131, in encode_assistant_message
    raise TokenizerException(f"Invalid assistant message: {message}")
TokenizerException: Invalid assistant message: role='assistant' content='' tool_calls=None prefix=False

Originating from:

File "vllm/entrypoints/anthropic/api_router.py", line 70, in create_messages
    generator = await handler.create_messages(request, raw_request)
File "vllm/entrypoints/anthropic/serving.py", line 422, in create_messages
    generator = await self.create_chat_completion(chat_req, raw_request)

What was tried

  1. --tool-call-parser mistral: crashes as described
  2. --tool-call-parser openai: with same mode, same crash
  3. External middleware normalizing content arrays to strings and injecting empty content where missing: no effect, because the invalid assistant message is generated inside vLLM's Anthropic adapter during Anthropic-to-OpenAI format conversion, not from the client request

Root cause analysis

The Anthropic adapter (vllm/entrypoints/anthropic/serving.py) converts Anthropic Messages format to OpenAI Chat Completions format. During this conversion on multi-turn tool calling, it produces an assistant message with content='' and tool_calls=None. The Mistral renderer (vllm/renderers/mistral.py) passes this to mistral_common, which requires assistant messages to have either non-empty content or tool_calls. The validation at instruct.py:1131 rejects the empty message.

Expected behavior

Multi-turn tool calling should work through the Anthropic Messages API with Mistral models, as documented at https://docs.vllm.ai/en/stable/serving/integrations/claude_code/

Related issues

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions