[Bug] llama3 tool-call parser silently deletes any leading JSON object from message content
Author: kvcache670Created Aug 19, 2026Updated Sep 26, 2026
Checklist
- I searched related issues but found no solution.
- The bug persists in the latest version.
- Issues without environment info and a minimal reproducible demo are hard to resolve and may receive no feedback.
- If this is not a bug report but a general question, please start a discussion at https://github.com/sgl-project/sglang/discussions. Otherwise, it will be closed.
- Please use English. Otherwise, it will be closed.
Describe the bug
Start a server with the llama3 tool-call parser:
python -m sglang.launch_server \
--model-path meta-llama/Llama-3.2-1B-Instruct \
--tool-call-parser llama3 \
--host 0.0.0.0 --port 30000Send a /v1/chat/completions request that has tools.
input = '{}' -> content = '' (the message is gone)
input = '{"a": 1} is a dict' -> content = 'is a dict' (the leading JSON is gone)Expected: if the parser finds no tool call, it must not change the text. The bug shows without a GPU or a server. The bug is in the parser class.
Reproduction
# pip install "sglang[all]==0.5.17" — no GPU or server needed
from sglang.srt.entrypoints.openai.protocol import Function, Tool
from sglang.srt.function_call.function_call_parser import FunctionCallParser
tools = [Tool(type="function", function=Function(name="get_weather", parameters={}))]
parser = FunctionCallParser.ToolCallParserEnum["llama3"]()
result = parser.detect_and_parse('{"a": 1} is a dict', tools)
print(repr(result.normal_text), result.calls) # 'is a dict' [] — {"a": 1} silently deleted
assert result.normal_text == '{"a": 1} is a dict', "leading JSON dropped from content"
Environment
Python: 3.12.13 (main, Jun 23 2026, 15:18:55) [Clang 22.1.3 ]
CUDA available: True
GPU 0: NVIDIA GeForce RTX 4090
GPU 0 Compute Capability: 8.9
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.9, V12.9.86
CUDA Driver Version: 580.173.02
PyTorch: 2.11.0+cu130
sglang: 0.5.17
sglang-kernel: 0.4.5
flashinfer_python: 0.6.15.post1
flashinfer_cubin: Module Not Found
flashinfer_jit_cache: Module Not Found
triton: 3.6.0
transformers: 5.12.1
torchao: 0.17.0
numpy: 2.3.5
aiohttp: 3.14.3
fastapi: 0.141.1
huggingface_hub: 1.28.0
interegular: 0.3.3
modelscope: 1.39.1
orjson: 3.12.0
outlines: 0.1.11
packaging: 26.3
psutil: 7.2.2
pydantic: 2.14.0b1
python-multipart: 0.0.32
pyzmq: 27.1.0
uvicorn: 0.52.4
uvloop: 0.22.1
vllm: Module Not Found
xgrammar: 0.2.1
openai: 2.6.1
tiktoken: 0.14.0
anthropic: 0.124.0Source: sgl-project/sglang