Validation error on the 2nd turn of chat completions (Pydantic missing 'name' in AssistantMessage) #143
-
|
Environment & Setup
Final answer... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Your diagnosis is right. This is a server-side schema validation issue, not something related to Cherry Studio, OpenWebUI, or Qwen3 reasoning mode. The failure happens before inference even starts. What’s happening is that turn 1 works because the request only contains a In the current fork, class ChatCompletionRequestAssistantMessage(TypedDict):
role: Literal["assistant"]
name: Optional[str]
content: NotRequired[Optional[str]]The issue is subtle but important. Most clients send assistant messages like this: {"role": "assistant", "content": "..."}There is no The other validation errors like “Input should be 'developer', 'system', 'user'” are just Pydantic evaluating the union of possible message types and failing each branch. The real root cause is the missing Upstream To answer your questions directly: This is not intentional. The This is also not related to reasoning mode or Qwen3. The error occurs during request validation in FastAPI/Pydantic before the model or chat template is even involved. Yes, this would affect any multi-turn request that includes assistant history in this fork. Qwen3 just makes it more visible because you are testing multi-turn reasoning flows. The fix is straightforward. In name: Optional[str]to: name: NotRequired[Optional[str]]Alternatively, remove This is the same class of issue that was already fixed in upstream for other fields like Until this is patched, you have a few workarounds. You can modify the client to always include There is a separate minor observation about empty assistant content. If the assistant message contains The A minimal patch would be: class ChatCompletionRequestAssistantMessage(TypedDict):
role: Literal["assistant"]
- name: Optional[str]
+ name: NotRequired[Optional[str]]
content: NotRequired[Optional[str]]This is worth reporting upstream or opening a PR for, since the fix is small and consistent with how other fields in the schema were corrected. |
Beta Was this translation helpful? Give feedback.
@handsomelcx
Your diagnosis is right. This is a server-side schema validation issue, not something related to Cherry Studio, OpenWebUI, or Qwen3 reasoning mode. The failure happens before inference even starts.
What’s happening is that turn 1 works because the request only contains a
usermessage. Turn 2 fails because Pydantic tries to validate the assistant message in the chat history againstChatCompletionRequestAssistantMessage, and it rejects it during validation.In the current fork,
llama_cpp/llama_types.pydefines the assistant message like this: