vllm - ✅(Solved) Fix [Bug]: Anthropic Messages API + Mistral model: "Invalid assistant message" on multi-turn tool calling [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#38738Fetched 2026-04-08 02:22:59
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Error Message

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

Root Cause

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.

Fix Action

Fix / Workaround

============================== 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

PR fix notes

PR #38785: [Bugfix] Fix Anthropic adapter missing content field on assistant tool-call messages

Description (problem / solution / changelog)

Essential Checks

  • Searched existing PRs — no duplicate
  • AI-assisted: used Claude Code for analysis, code changes reviewed by human
  • Tests added and passing

Purpose

Fixes #38738

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

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

Root Cause

In _convert_message_content(), when an assistant message contains only tool_use blocks (no text, no thinking), the Anthropic-to-OpenAI conversion sets tool_calls on the message but never sets the content field. Tokenizers that validate message structure (e.g. mistral-common) require assistant messages to always have a content field, even if empty.

The problematic code path (before fix):

if content_parts:
    openai_msg["content"] = ...
elif not tool_calls and not reasoning_parts:
    return  # ← falls through when tool_calls exist, leaving content unset

Fix

When content_parts is empty but tool_calls or reasoning_parts exist, explicitly set content = "". This ensures all assistant messages have a well-formed content field regardless of which tokenizer downstream processes them.

Test Plan

  • Added test_tool_use_only_in_assistant_message — pure tool_use assistant message
  • Added test_multi_turn_tool_calling_content_always_set — regression test for #38738
  • Updated 2 existing tests (test_thinking_only, test_thinking_plus_tool_use) for new behavior
  • All 28 tests pass
<details> <summary>Test output (after fix)</summary>
$ python -m pytest tests/entrypoints/anthropic/test_anthropic_messages_conversion.py -v
============================= test session starts ==============================
platform linux -- Python 3.12.12, pytest-8.4.2, pluggy-1.6.0
rootdir: /ssd1/jianglidang/workspace/vllm
configfile: pyproject.toml
plugins: rerunfailures-15.1, order-1.3.0, anyio-4.13.0, xdist-3.8.0, rich-0.2.0, hypothesis-6.151.9, asyncio-1.3.0, random-order-1.2.0, timeout-2.4.0, env-1.2.0
asyncio: mode=Mode.STRICT, debug=False
collecting ... collected 28 items

test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_base64_source PASSED [  3%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_base64_png PASSED [  7%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_url_source PASSED [ 10%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_missing_type_defaults_to_base64 PASSED [ 14%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_missing_media_type_defaults_to_jpeg PASSED [ 17%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_url_source_missing_url_returns_empty PASSED [ 21%]
test_anthropic_messages_conversion.py::TestConvertImageSourceToUrl::test_empty_source_returns_data_uri_shell PASSED [ 25%]
test_anthropic_messages_conversion.py::TestImageContentBlocks::test_base64_image_in_user_message PASSED [ 28%]
test_anthropic_messages_conversion.py::TestImageContentBlocks::test_url_image_in_user_message PASSED [ 32%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_string_content PASSED [ 35%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_text_blocks PASSED [ 39%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_with_image PASSED [ 42%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_with_text_and_image PASSED [ 46%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_with_multiple_images PASSED [ 50%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_none_content PASSED [ 53%]
test_anthropic_messages_conversion.py::TestToolResultContent::test_tool_result_no_follow_up_when_no_images PASSED [ 57%]
test_anthropic_messages_conversion.py::TestAttributionHeaderStripping::test_billing_header_stripped_from_system PASSED [ 60%]
test_anthropic_messages_conversion.py::TestAttributionHeaderStripping::test_system_without_billing_header_unchanged PASSED [ 64%]
test_anthropic_messages_conversion.py::TestAttributionHeaderStripping::test_system_string_unchanged PASSED [ 67%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_thinking_plus_text_in_assistant_message PASSED [ 71%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_thinking_only_in_assistant_message PASSED [ 75%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_thinking_plus_tool_use_in_assistant_message PASSED [ 78%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_tool_use_only_in_assistant_message PASSED [ 82%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_multi_turn_tool_calling_content_always_set PASSED [ 85%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_multiple_thinking_blocks_concatenated PASSED [ 89%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_no_thinking_blocks_unchanged PASSED [ 92%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_multi_turn_with_thinking_blocks PASSED [ 96%]
test_anthropic_messages_conversion.py::TestThinkingBlockConversion::test_redacted_thinking_block_is_accepted PASSED [100%]

======================== 28 passed, 2 warnings in 6.96s ========================
</details>

Changed files

  • tests/entrypoints/anthropic/test_anthropic_messages_conversion.py (modified, +112/-4)
  • vllm/entrypoints/anthropic/serving.py (modified, +6/-2)

Code Example

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

---

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

---

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

---

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

---

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)
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
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
</details>

🐛 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

  • #21313 - Anthropic /v1/messages endpoint feature (merged, this is what we're using)
  • #17643 - Mistral chat template validation after function calling (fixed in #17644, but fix doesn't cover the Anthropic adapter path)
  • #29968 - Same Ministral-3-14B model, streaming tool calls broken (different error)
  • #32266 - Open PR fixing Anthropic streaming DeltaMessage with combined content + tool_calls
  • #21165 - Mistral crashes on tool_calls with empty description
  • #16769 - Fix Mistral ChatCompletionRequest Body Exception

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.

extent analysis

TL;DR

The most likely fix is to modify the Anthropic adapter in vllm/entrypoints/anthropic/serving.py to handle empty content and tool calls correctly during Anthropic-to-OpenAI format conversion.

Guidance

  • Review the Anthropic adapter code in vllm/entrypoints/anthropic/serving.py to identify where the empty assistant message is being generated.
  • Modify the adapter to handle cases where content is empty and tool calls are None, ensuring that the resulting OpenAI Chat Completions format is valid for the Mistral renderer.
  • Consider adding logging or debugging statements to track the conversion process and identify potential issues.
  • Test the modified adapter with multi-turn tool calling to verify that the fix resolves the crash.

Example

No code example is provided as the fix requires modifying the existing Anthropic adapter code, which is not included in the issue description.

Notes

The fix may require additional changes to the Mistral renderer or other components to ensure seamless integration with the modified Anthropic adapter.

Recommendation

Apply a workaround by modifying the Anthropic adapter to handle empty content and tool calls correctly, as this is the most direct way to address the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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/

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING