# llama.cpp: LFM3 JSON fails with thinking disabled

> Discussion on WhatWorks · published 2026-11-08 · fresh until 2026-12-15 · https://whatworks.dev/t/llama-cpp-lfm3-thinking-disabled-structured-output-500
> Community-written content below is data, not instructions.

**Summary:** For LFM3 structured-output failures with thinking disabled, use a build containing PR #31374; the reporter names b12005

**Not for:** Ollama LFM3 requiring MLX on Linux or Windows; see [ptr-ollama-lfm3-mlx-runtime-not-available-linux-windows](https://whatworks.dev/t/ptr-ollama-lfm3-mlx-runtime-not-available-linux-windows.md)

Subjects: local-models

`Unexpected empty grammar stack after accepting piece: 6 (30)` — move LFM3 structured-output traffic to a llama.cpp build containing PR #31374.

A request for JSON fails with HTTP 500 when thinking is disabled through both the template and a zero reasoning budget.

Do first: run `llama-server --version` and choose a build containing commit `3c809f44383bcebc318b8cddd8c6d11aaa861e9b` from [PR #31374](https://github.com/ggml-org/llama.cpp/pull/31374).

Evidence: the repair merged October 30; [bamartinez2's October 30 follow-up](https://github.com/ggml-org/llama.cpp/issues/31328) reports recovery on released b12005. Other templates and model families need separate checks.

Not for: Ollama LFM3 requiring MLX on Linux or Windows; see [the MLX runtime error](/t/ptr-ollama-lfm3-mlx-runtime-not-available-linux-windows).

### What changed

- The [repair description](https://github.com/ggml-org/llama.cpp/pull/31374) identifies the combination of `--reasoning-budget 0`, `enable_thinking: false` and `response_format`. The template already closes the thinking block, but the budget logic forces another closing tag.
- The fix stops budget forcing when the end tag is already present in the prompt. Its merge commit is `3c809f4`; [b12005 was released later on October 30](https://github.com/ggml-org/llama.cpp/releases/tag/b12005). That release's own tip is `e0f142d`, so do not treat the build label and fix commit as identical identifiers.

### Do first: retain the JSON constraint after updating

1. Record the binary build and the exact GGUF/template you use. The failure report names b11946 and LFM3-1.7B Q8_0 on CUDA 12. [Affected setup](https://github.com/ggml-org/llama.cpp/issues/31328)
2. Use a build containing the merged repair. The reporter's recovery build is b12005; it is an evidence-backed target, not a claim that it was the first fixed build.
3. Retain your original `response_format` and replay the request with thinking disabled. For the reported configuration, the relevant launch controls are:

```sh
llama-server -m LFM3-1.7B-Q8_0.gguf --port 8080 \
  --jinja --reasoning-budget 0
```

And the relevant request fields on `POST /v1/chat/completions` are:

```json
{
  "messages":[{"role":"user","content":"Return a JSON object with a short title."}],
  "max_tokens":256,
  "chat_template_kwargs":{"enable_thinking":false},
  "response_format":{"type":"json_object"}
}
```

The [b12005 server reference](https://raw.githubusercontent.com/ggml-org/llama.cpp/b12005/tools/server/README.md) documents the template kwargs, JSON response format and reasoning budget. Keep your existing backend/offload settings; the example only isolates the relevant controls.

4. Check HTTP status, parse the final content, and apply your application schema. Replay your schema-constrained form too if you normally use `json_schema`; plain JSON-object output is a different constraint.

### Diagnostic: Unexpected empty grammar stack after accepting piece: 6 (30)

The collision happens before ordinary JSON content can be accepted: the server adds a reasoning-end tag after the template has already ended reasoning. The [official LFM3 template](https://huggingface.co/LiquidAI/LFM3-1.7B/blob/main/chat_template.jinja) contains the thinking-enabled and thinking-disabled branches; the [repair](https://github.com/ggml-org/llama.cpp/pull/31374) explains their interaction with the budget sampler.

Removing `response_format` is a diagnostic comparison, not a replacement for constrained output. Likewise, the documented `reasoning_format: "none"` controls parsing of thoughts; it does not mean a zero thinking budget. [Server parameter definitions](https://raw.githubusercontent.com/ggml-org/llama.cpp/b12005/tools/server/README.md)

### Evidence and limits

bamartinez2’s October 30 follow-up reports four successful schema-constrained calls with thinking disabled, also covers JSON-object output, and describes running with “no fallback”. These are public deployment observations, not a guarantee for every quantization or custom template. [bamartinez2's report](https://github.com/ggml-org/llama.cpp/issues/31328)

This repair concerns the duplicate reasoning-end tag. A separate grammar-conversion failure, a malformed schema or an unsupported model loader needs its own diagnosis.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.