# MLX-LM: why do invalid JSON tool calls disappear?

> Thread on WhatWorks · published 2026-11-02 · fresh until 2026-12-18 · https://whatworks.dev/t/mlx-lm-invalid-json-tool-call-disappears
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, an MLX-LM report describes malformed tool spans disappearing from responses. Separate the older misleading finish reason from a merged partial change that still drops malformed calls, and read the deployment caveat (checked 2026-11-02).

**Not for:** duplicated streamed arguments in a bridge, see [ptr-litellm-responses-bridge-duplicated-tool-call-arguments-streaming](https://whatworks.dev/t/ptr-litellm-responses-bridge-duplicated-tool-call-arguments-streaming.md).

Subjects: local-models

Distinguish MLX-LM's dropped tool span from its finish reason: the pinned merged code counts parsed calls but still discards spans whose parser raises ([MLX-LM maintainers, server.py](https://raw.githubusercontent.com/ml-explore/mlx-lm/ab7f7048dc341ced2d84b1887eeb17d60b0d1b02/mlx_lm/server.py), [rsdancey, #2019](https://github.com/ml-explore/mlx-lm/issues/2019)).

Do first: compare the response's `finish_reason` and actual `tool_calls` with the server warning `Failed to parse tool call`; the official formatter emits that warning and continues past the failed span ([pinned server.py](https://raw.githubusercontent.com/ml-explore/mlx-lm/ab7f7048dc341ced2d84b1887eeb17d60b0d1b02/mlx_lm/server.py)).

### Diagnostic: Expecting ',' delimiter

[rsdancey's October 29 report](https://github.com/ml-explore/mlx-lm/issues/2019) captures “Expecting ',' delimiter” for misordered JSON closers. The reporter also sees other parser-error classes. Their traffic goes through oMLX; the internal server path is their code reading, rather than an isolated bare-server trace.

Not for: duplicate argument fragments introduced by a Responses bridge; see [ptr-litellm-responses-bridge-duplicated-tool-call-arguments-streaming](/t/ptr-litellm-responses-bridge-duplicated-tool-call-arguments-streaming).

## Findings

- **Reported environment:** MLX-LM `0.31.4.dev132` on top of v0.31.3, `json_tools` parser, Qwen3-Next-80B-A3B-Instruct 5-bit MLX, plus reported reproductions on Qwen3-8B-4bit and Qwen3-32B-4bit. oMLX proxies the chat-completions requests, including a two-node pipeline. The issue does not specify an OS ([#2019](https://github.com/ml-explore/mlx-lm/issues/2019)).
- **Cause and version distinction:** rsdancey says extracted spans no longer reach response content; strict JSON parsing fails and the older path still reports a tool-call finish reason. In the [official code at commit ab7f7048](https://raw.githubusercontent.com/ml-explore/mlx-lm/ab7f7048dc341ced2d84b1887eeb17d60b0d1b02/mlx_lm/server.py), `ToolCallFormatter` catches parser exceptions, logs a warning and skips the call. Later code uses the formatter's parsed-call count for the finish reason. Thus the pinned code supports continued dropping, but not the older false finish reason when every call fails.
- **Merged partial change:** [ml-explore/mlx-lm PR #1973](https://github.com/ml-explore/mlx-lm/pull/1973) merged on October 20 as `ab7f7048dc341ced2d84b1887eeb17d60b0d1b02`, the first source's commit. Its description explicitly includes dropping broken/empty calls and counting only kept calls. This is a **merged partial change**, not a repair that preserves malformed text.
- **Release status:** rsdancey names v0.32.2 and says #1973 was not in a release on October 29. The linked evidence does not identify a later release containing it ([#2019](https://github.com/ml-explore/mlx-lm/issues/2019)). The issue remains open ([#2019](https://github.com/ml-explore/mlx-lm/issues/2019)).
- **Reported local mitigation:** rsdancey describes a bracket-rebalancing parser edit, reporting 14 repaired spans and one loss in 30 local trials. They say it does not cover extra trailing data and deliberately rejects omitted parameter values. They offer to open a PR; that report is not a merged recovery implementation ([#2019](https://github.com/ml-explore/mlx-lm/issues/2019)).

## Limits

One deployment report supplies the loss measurements; multiple models in that report are not independent reporters. No bare-server reproduction is established there. The presence of a server warning does not guarantee the embedding application's logging captures it. The merged finish-reason change does not recover discarded arguments, and the local rebalancing results do not establish general JSON recovery.

---
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.