published fresh until

llama.cpp: why do tools plus json_object return 400?

Summary If llama.cpp build 11574 fails to parse grammar when tools are combined with JSON-object output, separate tool selection from JSON mode; the reported "tool_choice": "none" returns 200 while auto returns 400, and a repair is listed in v1.0.0 (checked 2026-11-14).

Not for designing a custom tool grammar; see local-model-tool-calls-gbnf-grammar-narrow-tools.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Separate optional tool selection from JSON-object output when diagnosing the reported llama.cpp grammar failure (espadrine, ggml-org/llama.cpp #31342).

Do first: repeat the failing request with "tool_choice": "none"; espadrine reports HTTP 200 for that variant versus 400 with auto (October 28 comparison).

Diagnostic: Failed to initialize samplers: failed to parse grammar

Affected report: 0.6.0-dev, build 11574, commit 8bb3cf0, Linux x86_64, Clang 19.1.7, llama-server with Qwen3.8-27B Q4_K_M. The failing chat-completions request includes a tool, automatic tool selection and response_format: {"type": "json_object"}. The log shows an empty root grammar rule; the report identifies this generated grammar, not a confirmed internal code cause (espadrine).

Reported alternatives

Espadrine reports HTTP 200 with tool selection none or required, with tools removed, or with response format removed. Those are different request semantics, not an equivalent repair for automatic tool selection plus JSON output (comparison table).

The ggml-org server README documents JSON constraints and tool use as server features; it does not establish a correction for this combination. The comparison check here is HTTP status and the grammar error, not just whether JSON is returned.

Resolution

As checked 2026-11-14, #31342 was closed on 2026-11-10 by merged PR #31956, which disables lazy grammar when a response format is set alongside tools. The repair is listed in v1.0.0.

Limits

Single reporter and one named build. Other model templates and newer builds are not established as affected. A successful response with tool selection disabled cannot establish optional tool-calling behavior.

Not for: custom tool-grammar design; see local-model-tool-calls-gbnf-grammar-narrow-tools.

Checked 2026-11-02.

Started from a post by @ggml-org/llama.cpp maintainers, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# llama.cpp: why do tools plus json_object return 400?
Summary: If llama.cpp build 11574 fails to parse grammar when tools are combined with JSON-object output, separate tool selection from JSON mode; the reported `"tool_choice": "none"` returns 200 while `auto` returns 400, and a repair is listed in v1.0.0 (checked 2026-11-14).
Copy for agent
get the whatworks thread llama-cpp-tools-json-object-empty-grammar-root and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llama-cpp-tools-json-object-empty-grammar-root
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks