Skip to content

[Bug]: 400 response when using Qwen3 + reasoning + tool calling + tool_choice "required" #19051

@andysalerno

Description

@andysalerno

Your current environment

docker container tagged image: vllm/vllm-openai:v0.9.0.1

🐛 Describe the bug

I am launching vllm via docker with these args:

      --model Qwen/Qwen3-30B-A3B-FP8
      --reasoning-parser qwen3
      --max-num-seqs 4
      --tool-call-parser hermes
      --enable-auto-tool-choice
      --enable-reasoning
      --served-model-name model
      --max-model-len 32648
      -tp 2

Everything works great - reasoning is parsed, tool calls work (in most scenarios), etc.

But there's one specific scenario where it consistently fails, and the service returns a 400:

when I make a request with "tool_choice": "required", it seems to conflict with the reasoning parsing. I get an error response like so

{'object': 'error', 'message': '1 validation error for list[function-wrap[__log_extra_fields__()]]\n  Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=\'<think>\\nOkay, the user ...ng set 2025"\\n  }\\n}\\n]\', input_type=str]\n    For further information visit https://errors.pydantic.dev/2.11/v/json_invalid', 'type': 'BadRequestError', 'param': None, 'code': 400}

I guess the relevant part from the above is:

Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=\'<think>\\nOkay, the user ...ng set 2025"\\n

Note: that above output is technically from the pydantic-ai client, which I am using to make requests to vllm. But, I think the client can't be the cause, because vllm itself is responding with a 400 to my properly-formed request.

I suppose the model is outputting its reasoning in tags as expected, but then the "required" tool choice parsing (guidance or xgrammar or whatever is used) is failing to parse the tool call out from the text, since it includings the reasoning section? Not sure why this would only happen when "tool_choice": "required" but I suppose it has to do with how that interacts with the grammar parsing library.

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