server: fix json_schema response_format handling#4
Merged
superbarne merged 2 commits intomasterfrom Mar 15, 2026
Merged
Conversation
- Add validation that json_schema.schema is present when using response_format.type: "json_schema" - Update error message for invalid response_format types to include "json_schema" - Add test cases for json_schema validation and error messages Co-authored-by: superbarne <1502820+superbarne@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Merge pull request #18963 from ggml-org/llama.cpp
server: fix json_schema response_format handling
Mar 15, 2026
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.
Make sure to read the contributing guidelines before submitting a PR
Merges upstream ggml-org/llama.cpp#18963.
When
response_format.typeis"json_schema"butjson_schema.schemais missing, the server silently falls back to an empty schema{}which matches any JSON — effectively no constraint at all.Changes:
tools/server/server-common.cpp: Validate thatjson_schema.schemais present; throw if missing. Update the invalid-type error message to list"json_schema"as a valid option.tools/server/tests/unit/test_chat_completion.py: Add test cases for OpenAI-stylejson_schemawith extra fields (name,strict), missingschemafield (expect 400), and error message content assertions.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.