现场是这样的。vLLM 用 OpenAI 兼容接口部署 Qwen2.5-72B,传 tools 之后模型把调用写进 content,tool_calls 始终为空,客户端按函数调用解析拿不到参数。

中间走过弯路,把「chat template 版本旧 没带工具段」当成主因,改完现象没变。

排查方向其实有限,先把可能性排一排。启动时没有指定工具调用解析器;模型输出格式与默认解析器不匹配;客户端把 content 里的 JSON 当成普通文本。

动手时先看模型的原始输出格式

curl -s http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' -d @tool_req.json | jq '.choices[0].message'

再往下启动时加上对应解析器

python -m vllm.entrypoints.openai.api_server --model Qwen/Qwen2.5-72B-Instruct --enable-auto-tool-choice --tool-call-parser hermes

接着确认模板里带工具段

python -c "from transformers import AutoTokenizer;t=AutoTokenizer.from_pretrained('Qwen/Qwen2.5-72B-Instruct');print('tools' in t.chat_template)"

末了重启后回归一次工具调用

python eval_tool.py --base http://127.0.0.1:8000/v1 --n 20

改之前先确认了最近有没有人动过配置,避免白查一遍。

这次没动代码,只在配置和运行环境上找原因。

怎么算真的好了,看的是同一批现象。tool_calls 里能拿到 name 与 arguments,content 为空,二十次调用全部解析成功。

兼容层不会自动猜模型的函数调用格式,parser 必须和模型对得上,否则只能拿到一段文本。报错文案容易误导,真正的原因往往在相邻那一层的日志里。

作者 9823189