Skip to content

[BUG] vLLM rejects messages because content is a nested list [[...]] generated by mcp_agent (works on OpenAI/OpenRouter) #1396

@doubleclip118

Description

@doubleclip118

Describe the bug

When Aperag (via mcp_agent) calls a tool and sends the request to a self-hosted vLLM OpenAI-compatible server, the outgoing payload contains messages[*].content as a nested list ([[{...}]]) instead of a string or a flat parts array ([{...}]).
vLLM performs strict schema validation and returns 400 BadRequest:
Message content.0 Input should be a valid dictionary or instance of Content [type=model_type, input_value=[{'text': '{\n "items": ... }\n', 'type': 'text'}], input_type=list]
The exact same payload succeeds against OpenAI or OpenRouter (they likely normalize it). This makes Aperag fail only when the provider is vLLM.

To Reproduce

Steps to reproduce the behavior:

Configure Aperag to use a vLLM OpenAI endpoint (e.g. vllm/vllm-openai).

Use a model that supports tool calling (e.g. openai/gpt-oss-120b) and enable auto tool choice.

Trigger any tool call (e.g. a simple “list_collections” or similar).

Observe Aperag sending a request where messages[0].content is [[{ "type":"text","text": "..." }]] (double-wrapped).

vLLM responds with 400 and the Pydantic message shown above.

Screenshots & Logs

`Error code: 400 - {'error': {'message': '1 validation error for
Message
content.0
Input should be a valid dictionary or instance of Content
[type=model_type, input_value=[{'text': '{\n "items": ... }\n}',
'type': 'text'}], input_type=list]
... ', 'type': 'BadRequestError', 'code': 400}}

[INFO] ... Requesting tool call
... "tool_name": "list_collections"
... "GET /api/v1/collections" 200
... then 400 from vLLM as above
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions