Repository navigation
fix(server): tolerate missing/null content in chat messages - #91
Merged
Merged
Conversation
OpenAI-compatible clients omit `content` (or send `content: null`) on assistant messages that carry `tool_calls`. Because `Message.content` was a required, non-nullable field, axum's `Json` extractor rejected the follow-up request of any multi-turn tool-calling loop with HTTP 422 (`missing field 'content'`) before the handler ran, breaking agentic tool use. llama-server tolerates this, so the incompatibility was mlxcel-specific. `MessageContent` now implements `Default` (empty text) and the field uses `#[serde(default, deserialize_with = ...)]`: a missing key falls back to the default, an explicit `null` is mapped to empty content by the custom deserializer, and normal string / multimodal arrays are unaffected. Keeping the field typed as `MessageContent` (not `Option`) leaves every consumer and constructor untouched, and `build_raw_json_messages` keeps emitting a `"content"` key (empty string when absent) so Jinja chat templates that read `message.content` keep rendering. Adds type-level unit tests (default, missing, null, string, multimodal) and request-level regression tests for the issue's exact reproduction and the empty-content rendering guarantee.
inureyes
added a commit
that referenced
this pull request
May 26, 2026
Bump version to 0.0.31. Highlights: MiniCPM-V 4.6 and RT-DETRv2 model support plus an Anthropic-style /v1/messages API endpoint (#82, #80, #74); fixes for missing or null chat-message content, Gemma 3n VLM per_layer_inputs, Qwen3.5 MTP verify attention, and batched quantized KV cache mask offsets (#91, #86, #78, #76); and a pinned 1.93.1 Rust toolchain (#87, #90).
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
OpenAI-compatible clients omit `content` (or send `content: null`) on assistant messages that carry `tool_calls`. Because `Message.content` was a required, non-nullable field, axum's `Json` extractor rejected the follow-up request of any multi-turn tool-calling loop with HTTP 422 (`missing field 'content'`) before the handler ran, breaking agentic tool use. llama-server tolerates this, so the incompatibility was mlxcel-specific. `MessageContent` now implements `Default` (empty text) and the field uses `#[serde(default, deserialize_with = ...)]`: a missing key falls back to the default, an explicit `null` is mapped to empty content by the custom deserializer, and normal string / multimodal arrays are unaffected. Keeping the field typed as `MessageContent` (not `Option`) leaves every consumer and constructor untouched, and `build_raw_json_messages` keeps emitting a `"content"` key (empty string when absent) so Jinja chat templates that read `message.content` keep rendering. Adds type-level unit tests (default, missing, null, string, multimodal) and request-level regression tests for the issue's exact reproduction and the empty-content rendering guarantee.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
Bump version to 0.0.31. Highlights: MiniCPM-V 4.6 and RT-DETRv2 model support plus an Anthropic-style /v1/messages API endpoint (lablup#82, lablup#80, lablup#74); fixes for missing or null chat-message content, Gemma 3n VLM per_layer_inputs, Qwen3.5 MTP verify attention, and batched quantized KV cache mask offsets (lablup#91, lablup#86, lablup#78, lablup#76); and a pinned 1.93.1 Rust toolchain (lablup#87, lablup#90).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Multi-turn tool-calling against mlxcel's
/v1/chat/completionsfailed at the second round: OpenAI-compatible clients omitcontent(or sendcontent: null) on assistant messages that carrytool_calls, butMessage.contentwas a required, non-nullable field, so axum'sJsonextractor rejected the follow-up request with HTTP 422 (missing field 'content') before the handler ran.llama-servertolerates this, so the incompatibility was mlxcel-specific and broke agentic tool loops at the first tool round.Fix
MessageContentnow implementsDefault→ empty text.Message.contentuses#[serde(default, deserialize_with = "deserialize_message_content")]: a missing key falls back to the default; an explicitnullis mapped to empty content by the custom deserializer; normal string / multimodal content is unaffected.MessageContent(notOption<…>), so every existing consumer (content.text()) and constructor is untouched.build_raw_json_messageskeeps emitting a"content"key — empty string when absent — so Jinja chat templates that referencemessage.contentkeep rendering (issue follow-up chore: complete OSS release rollout #1).Tests
request.rs: type-level unit tests —Defaultis empty text, deserialize with missing field, explicitnull, plain string, and multimodal array.chat_request_tests.rs: the issue's exact 3-message reproduction deserializes, andbuild_raw_json_messagesemits"content": ""for atool_callsmessage that omitted content.Verified with
cargo fmt --check,cargo clippy --all-targets --features metal,accelerate -- -D warnings, and the targeted test run (9/9 pass).Fixes #89