Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a400ded
test(provider): `parallel_tool_calls: false` keeps the first call ins…
jonathan308 Nov 13, 2026
eb76309
test(provider): a stray <tool_call> in GLM output is text, not a 500 …
jonathan308 Nov 13, 2026
fc06c86
test(provider): Qwen3.5-9B keeps the card's presence penalty; a rollb…
jonathan308 Nov 13, 2026
37f0e62
fix(provider): Qwen3.5-9B keeps the model card's presence penalty; a …
jonathan308 Nov 13, 2026
ca52aa7
fix(provider): `parallel_tool_calls: false` returns the first call in…
jonathan308 Nov 13, 2026
bf4eac8
fix(provider): a stray <tool_call> in GLM output is text, not a 500
jonathan308 Nov 13, 2026
221f1b4
refactor(provider): refactor pass on the GLM tool suffix fix
jonathan308 Nov 13, 2026
7fb1f8d
test(provider): named choice and a clean call at the token limit; exa…
jonathan308 Nov 13, 2026
faf818c
fix(provider): GLM suffix calls come only from top-level frames (review)
jonathan308 Nov 13, 2026
0d73e28
refactor(provider): one ParallelToolCallPolicy; the router drops late…
jonathan308 Nov 13, 2026
78febeb
test(provider): review findings on #2049: the stale Super test, faile…
jonathan308 Nov 13, 2026
15f7d67
docs(provider): #2049's wording after review: the prompt, malformed l…
jonathan308 Nov 13, 2026
113bbbe
Merge #2049 (15f7d676e9) into #2052's fold resolution
jonathan308 Nov 13, 2026
0c37db5
Merge #2051 (37f0e6277a) into #2052's fold resolution
jonathan308 Nov 13, 2026
98a9cde
refactor(provider): the 9B penalty fix's wording and names (review-20…
jonathan308 Nov 13, 2026
531ddff
test(provider): the second review's findings on #2052 (red)
jonathan308 Nov 13, 2026
3779320
fix(provider): the second review's findings on #2052
jonathan308 Nov 13, 2026
46a47ef
test(provider): the third review's findings on #2052 (red)
jonathan308 Nov 13, 2026
c62caaf
fix(provider): the third review's findings on #2052
jonathan308 Nov 13, 2026
e7c14d0
refactor(provider): refactor pass on the final GLM tool suffix fix
jonathan308 Nov 13, 2026
e33365d
test(provider): the fourth reviews' findings on #2052 (red)
jonathan308 Nov 13, 2026
e0922a9
fix(provider): the fourth reviews' findings on #2052
jonathan308 Nov 13, 2026
43be515
test(provider): the fifth review's findings on #2052 (red)
jonathan308 Nov 13, 2026
bd0bdd2
test(provider): the second fifth review's findings on #2052 (red)
jonathan308 Nov 13, 2026
9415d34
fix(provider): the fifth reviews' findings on #2052
jonathan308 Nov 13, 2026
afa6697
refactor(provider): refactor pass on 9415d3439b; the sixth reviews' NITs
jonathan308 Nov 13, 2026
f64d2fe
test(provider): the sixth review's finding on #2052 (red)
jonathan308 Nov 13, 2026
91ae652
fix(provider): the sixth review's finding on #2052
jonathan308 Nov 13, 2026
1bc5c34
Merge #2052's frozen head (91ae6525ec) into its fold resolution
jonathan308 Nov 13, 2026
0d2ec9e
Merge #2051's head (98a9cded8c) into #2052's fold resolution
jonathan308 Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/glm-stray-tool-call-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### A stray `<tool_call>` no longer fails a GLM-5.3-Flash response

- GLM's tool parser reads a response from its first `<tool_call>` to the end as one batch of calls, and on `auto` tool requests that includes the model's reasoning. A tag the model only mentioned or a call it drafted in its thought, or a text answer that mentions the tag, failed the whole response with a 500 (`native GLM tool output is invalid`).
- Such output is now text instead of a failure, as vLLM's and SGLang's GLM parsers never fail a response on tool syntax, with a stricter rule for what is still a call: the calls are the frames that end the response, when all of them are well-formed; everything before them is text, which the service's reasoning parser splits at `</think>`. A frame inside or after another frame's arguments, or after arguments that break the parser's grammar, is never a call. Output with no such calls (a malformed or cut-off final call, a malformed call among the final ones, text after the calls) is all text, and so is output cut off at `max_tokens` whose tool suffix does not parse. No call is completed or salvaged.
- Still a 500, as before: output whose released text would hold a think marker from inside a tool frame (the reasoning parser would read it as the end of the thought), and a tool suffix over the parser's 1 MiB bound. Output the parser cannot read safely, such as a thought that spells out the tags in order (`<tool_call>`, `<arg_key>`, `<arg_value>`) or a refused call with quotes before the final calls, recovers no call: it is text, or still a 500 when the thought's `</think>` comes after it. Required and named `tool_choice` still fail closed (422). `DARKBLOOM_GLM_TOOL_TEXT_FALLBACK=0` restores the 500 for every unparsed suffix; `darkbloom start` passes it to the launchd provider.
4 changes: 4 additions & 0 deletions changelog.d/parallel-tool-calls-false-first-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### `parallel_tool_calls: false` returns the first tool call instead of failing the response

- With `parallel_tool_calls: false`, a model that made a second call failed the whole response: a streamed answer ended in an error after its first call had already been sent, and a complete answer was a 422. Under automatic tool choice the prompt does not ask for a single call (only a GLM pair's prompt does), so these were requests the provider should have served.
- The response now carries the first call, as OpenAI and vLLM return it, and the calls the model makes after it are dropped, streamed or not, on every model, Nemotron Super's path included. A later frame that does not parse keeps the existing rule for malformed output: GLM, MiMo, Flint and Nemotron Super fail the response, as for any malformed frame, and a frame that never reads as a call (an undeclared name on Qwen or Gemma) stays text.
5 changes: 5 additions & 0 deletions changelog.d/qwen35-9b-card-presence-penalty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Qwen 3.5 9B keeps its model card's presence penalty

- Provider 0.10.12 dropped the default `presence_penalty` of 1.5 from the catalog `Qwen3.5-9B` for requests that send none. In production its answers with `max_tokens` of 8,192 or more then ran to the limit about three times as often (5.5 % against 1.7 % on 0.10.11), and JSON `response_format` answers ran out and failed about twice as often (51 % against 23 % in the same 10-minute windows). 0.10.13 restores the model card's 1.5 for those requests, as on the other catalog Qwen 3.5/3.6 builds.
- A request that sends its own `presence_penalty` is unchanged. With `presence_penalty` 0 the 9B still speculates under exact MTP acceptance. A penalty row does not speculate but still donates prefix-cache checkpoints.
- `DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0` (or `off`) restores 0.10.12's default. `darkbloom start` passes it to the launchd job. A coordinator registry `presence_penalty` arrives as the request's own value and wins, so while the registry sets one for the 9B the switch changes only local requests; rolling routed traffic back also needs the registry value removed or set to 0.
92 changes: 69 additions & 23 deletions docs/architecture/inference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provider inference engine

> Last updated: 2026-11-12
> Last updated: 2026-11-13

How a chat-completion request is served inside the `darkbloom` provider
process: one in-process engine (`mlx-swift-lm`
Expand Down Expand Up @@ -1781,6 +1781,45 @@ commit a partial call batch. Its retained suffix is capped at 1 MiB; rejection
returns the original text through the existing parser-failure path. Ambiguous
string unions and unsupported indirect schemas are not inferred. This parser
does not implement constrained decoding or advertise function calling.
The suffix starts at the response's first `<tool_call>`, and GLM `auto` tool
requests do not split reasoning off first, so it also holds a tag the model only
mentioned or a call it drafted in its thought, or a tag its answer mentions.
Such a suffix does not parse as one batch. On an `auto` request it is no longer a
failure: like the reference GLM parsers (vLLM, SGLang), which never fail a
response on tool syntax, the provider returns it as text, under its own stricter
rule for what still counts as a call (`NativeToolStreamRouter.finishCompleteCalls`,
`GLM5ToolSuffix`). The calls are the trailing run of top-level frames, separated
only by whitespace and ending the response, when the SDK parser accepts every one
of them (like the SDK, the batch is taken whole or not at all); everything before
them is text, which the service's reasoning parser then splits at `</think>`. A frame that has started its
arguments must follow the SDK parser's grammar to its own `</tool_call>` (a
string-typed value raw to `</arg_value>`, any other value structurally valid
JSON, whose quoted delimiters are data). One that does not (malformed JSON, a raw
value holding frame tags, which the SDK refuses, its own tags after a malformed
header, a key that only canonically equals a declared one, a value whose declared
type is a union of `string` with `object` or `array`, which the template could
have written either way) or that is still open at the end owns the rest of the
response: no frame inside or after its arguments is ever a call. Where the SDK
accepts a frame on its own, the lexer reads it as the SDK does; a frame the SDK
refuses keeps its end only without a `"` (one may open a JSON string that a raw
reading ends inside, or end a raw string that a JSON reading runs past), else it
owns the rest too, as does a frame's tag in top-level text (from the first
frame or `<tool_call>` read as a mention before it). A `<tool_call>`
followed by anything else, with no frame tags before the next `<tool_call>`, is a
mention; a thought that spells out the tags in order (`<arg_key>` … `</arg_value>`)
therefore owns the rest, and fails as before when its `</think>` follows. A suffix
with no such run (a malformed or cut-off final frame, text after the calls) is
all text, and so is a suffix that did not parse in an output cut at the token
limit; no frame is completed or salvaged. A suffix whose release would put a think marker from
inside a frame (its name, a key or a value, or anything after a frame that owns
the rest) before the reasoning parser keeps failing (500), at a stop or at the
token limit, as does a suffix the SDK refuses as oversized while it streams, and
a required or named call (422). Unlike vLLM and SGLang, a call followed by text
or by a malformed frame, or next to one in the final run, commits nothing, and a
call drafted inside a closed thought stays reasoning. A suffix that parses keeps its calls as before. The
rule follows the handler's `glm5` parser format, so a request that selects that
parser for another family gets it too. `DARKBLOOM_GLM_TOOL_TEXT_FALLBACK=0`
restores the whole-suffix failure (500).
The request-local [GLM prompt contract](../reference/protocol-messages.md#glm-native-prompt-contract)
also preserves original schema values only after a trusted loaded-model check.
It renders reasoning that OpenRouter returns on earlier assistant turns
Expand Down Expand Up @@ -2958,7 +2997,9 @@ When neither a global nor a per-model acceptance value is configured, serving
defaults to typical acceptance for eligible sampled target-prefix rows, except
on the builds whose built-in rule is exact (`MTPAcceptancePolicy.builtInIsExact`):
the owned Bonsai 9B candidate; the catalog `Qwen3.5-9B`, which looped under
typical acceptance in the 0.10.12 gate (see the Qwen 3.5/3.6 defaults below);
typical acceptance in the 0.10.12 gate (its default carries the card's presence
penalty again, so only its rows with `presence_penalty` 0 draft; see the Qwen
3.5/3.6 defaults below);
the catalog `gemma-4-26b-qat-4bit`, which drafted every answer of OpenRouter's
10-31 GPQA run, 30 % of which ended at the 32,768-token cap; and every Qwen 3.8
27B build (`EigenLabs/Qwen3.8-27B-4bit-mtp` and its head-less target,
Expand Down Expand Up @@ -3095,7 +3136,7 @@ production assembly and encrypted store.
| `top_p` | `topP` | artifact default, else `1.0` |
| `top_k` | `topK` | artifact default, else `0` |
| `repetition_penalty` | `repetitionPenalty` | artifact default, else `1.0` |
| `frequency_penalty` / `presence_penalty` | `frequencyPenalty` / `presencePenalty` | `0`; `presence_penalty` takes a model-card default on the catalog 35B Qwen 3.5/3.6 builds (`Qwen3.5-9B` has none) |
| `frequency_penalty` / `presence_penalty` | `frequencyPenalty` / `presencePenalty` | `0`; `presence_penalty` takes the model card's 1.5 on the catalog Qwen 3.5/3.6 builds (`DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0` drops it on `Qwen3.5-9B`) |
| `seed` | `seed`; also keys a stable engine request id | nil |
| `logit_bias` | `logitBias` — string keys parsed to non-negative `Int`; invalid keys dropped and counted | `[:]` |
| `logprobs` + `top_logprobs` | `topLogprobs = logprobs ? min(20, max(1, top_logprobs ?? 0)) : 0` | `0` |
Expand Down Expand Up @@ -3153,29 +3194,27 @@ The catalog `Qwen3.5-9B`, `qwen3.5-35b-a3b` and `qwen3.6-35b-a3b-vl-mtp-mxfp8`
builds (`EngineV2SamplingDefaults.qwen35CardModelTypes`, each bound to its
`model_type`) take their model cards' thinking-mode values for omitted knobs:
`temperature 1.0`, `top_p 0.95`, `top_k 20`. Greedy decoding made them repeat
themselves until `max_tokens` (#1530). The cards' `presence_penalty 1.5` is a
per-build default, set by the 0.10.12 gate on the signed 0.10.11 (temperature 1
/ 0.95 / 20; #1652's four loopers and five tool transcripts at 32,768 tokens and
nineteen everyday prompts at 8,192, three seeds each; the Studio M3 Ultra for
the 9B, an M5 Ultra for the 35B):
themselves until `max_tokens` (#1530). Every build also takes the cards'
`presence_penalty 1.5` for a request that omits one (`qwen35CardDefaults`):

| Build | Omitted `presence_penalty` | Built-in MTP acceptance | The gate without the penalty |
| Build | Omitted `presence_penalty` | Built-in MTP acceptance | Without the penalty |
|---|---|---|---|
| `qwen3.5-35b-a3b`, `qwen3.6-35b-a3b-vl-mtp-mxfp8` (`qwen35CardDefaults`) | 1.5 | typical | `qwen3.5-35b-a3b` ran away under typical acceptance (5 of 19 everyday prompts, 8 of 12 loopers to 32,768, MTP running at concurrency 1) and under exact (2 of 12 loopers); the 3.6 build shares its architecture |
| `Qwen3.5-9B` (`qwen35NineBCardDefaults`) | none | **exact** (`MTPAcceptancePolicy.builtInIsExact`) | ran away on 13 of 31 draws under typical acceptance and on 0 of 31 under exact, MTP running; the penalty-free body cached 8,192 tokens on the second send, the penalty body none |
| `qwen3.5-35b-a3b`, `qwen3.6-35b-a3b-vl-mtp-mxfp8` | 1.5 | typical | The 0.10.12 gate on the signed 0.10.11 (temperature 1 / 0.95 / 20; #1652's four loopers and five tool transcripts at 32,768 tokens, nineteen everyday prompts at 8,192, three seeds each; an M5 Ultra): `qwen3.5-35b-a3b` ran away under typical acceptance (5 of 19 everyday prompts, 8 of 12 loopers to 32,768, MTP running at concurrency 1) and under exact (2 of 12 loopers); the 3.6 build shares its architecture |
| `Qwen3.5-9B` | 1.5; none under `DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0` (`qwen35NineBNoPenaltyDefaults`, 0.10.12's default) | **exact** (`MTPAcceptancePolicy.builtInIsExact`) | The same gate (the Studio M3 Ultra) saw it run away on 13 of 31 draws under typical acceptance and on 0 of 31 under exact, so 0.10.12 shipped it without the penalty. In production that was a regression. On 2026-11-12, on 0.10.12 Macs against 0.10.11 Macs (the penalty, MTP off) over the same period, answers with `max_tokens` ≥ 8,192 hit the cap on 5.5 % against 1.7 %, about three times as often. On the 4,096-token JSON `response_format` workload, in the same 10-minute windows, answers ran out and failed in 51 % of requests against 23 %. Its constrained JSON rows never speculate and their template is unchanged since 0.10.4, so the penalty is the difference we can establish: with nothing else running they failed 32.7 % against 13.6 %. A registry `presence_penalty` 1.5 brought both back within the hour |

A row with a penalty does not speculate (`EngineLoopV2.mtpBasicEligible`), so
the 35B builds' requests that omit the penalty stay without MTP, the cost the
gate accepted for loop safety; they still stage prefix checkpoints
these builds' requests that omit the penalty stay without MTP, the cost taken
for loop safety. They still stage prefix checkpoints
([prefix caching](prefix-cache.md#invariants), invariant 9). A request's own
`presence_penalty` always wins: `0` on a 35B build speculates under typical
acceptance and donates checkpoints (the configuration that looped in the gate,
now the caller's choice); a nonzero value on the 9B turns its MTP off for that
request (it still donates checkpoints). The coordinator forwards a build's
registry runtime defaults for the fields a request omits
([`requestRuntimeDefaultKeys`](https://github.com/Layr-Labs/darkbloom-platform/blob/c69380d91fd3f9e4ef3ff1e3775690d80adbbe57/coordinator/api/inference/request/model_runtime_defaults.go));
on 2026-11-10 the registry set `temperature`, `top_p` and `top_k` for these
builds and no `presence_penalty`, so the provider default above decides it.
`presence_penalty` always wins: `0` speculates (typical acceptance on the 35B
builds, the configuration that looped in the gate; exact on the 9B) and donates
checkpoints. The coordinator forwards a build's registry runtime defaults for
the fields a request omits
([`requestRuntimeDefaultKeys`](https://github.com/Layr-Labs/darkbloom-platform/blob/a9c111db3e235fa979a914d6a46bf93cba8e4268/coordinator/api/inference/request/model_runtime_defaults.go),
`presence_penalty` included). Since 2026-11-12 19:17Z the registry sets
`presence_penalty` 1.5 on `Qwen3.5-9B`, which reaches 0.10.12 Macs too; to
the provider it is the request's own value, so `DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0`
changes nothing while the registry sets it.

Other model identities keep the legacy defaults in the table byte-for-byte. `do_sample: false` or an absent/unreadable file is legacy. The
sampler is not part of prompt or cache identity, so prefix-cache and SSD
Expand Down Expand Up @@ -3543,8 +3582,15 @@ read bare scalars and composites as raw strings. When the frame closes, the
complete parse must agree with everything already exposed
(`libs/mlx-swift-lm/Libraries/MLXLMCommon/Tool/ToolCallStreaming.swift`).
`NativeToolStreamRouter` admits `parallel_tool_calls` cardinality at the first
fragment and, when the request is `strict` (below), validates name and schema
at frame close; the service renders OpenAI fragments (`index`, `id`, `type`
fragment: with `parallel_tool_calls: false` it exposes the first call only and
drops every later call frame, unexposed and unvalidated, as OpenAI returns one
call and vLLM keeps the first; the complete-call paths, Nemotron Super's
included, keep the first the same way (`ParallelToolCallPolicy`). A later
frame keeps its family's malformed-output rule: one the parser returns as
text (an undeclared name it cannot read) stays visible text, and one that does
not parse still fails a GLM, MiMo, Flint or Nemotron Super response. When
the request is `strict` (below), it validates name and schema at frame close;
the service renders OpenAI fragments (`index`, `id`, `type`
and `function.name` first, then `function.arguments` pieces). A response that
begins with a call therefore reaches its first content frame at the function
name instead of the engine terminal, which also ends the frame loop's
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/prefix-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ rules applied to these signals.
text request that cannot speculate (a token constraint, logprobs,
`logit_bias`, a repetition, frequency or presence penalty, a `stop` string:
`EngineLoopV2.mtpBasicEligible`), including a Qwen request with the card's
presence penalty (the 35B builds' default), records the head's history over
presence penalty (every catalog Qwen 3.5/3.6 build's default), records the head's history over
its prompt chunks. It therefore stages the same resident and SSD
checkpoints a speculating request stages, byte for byte. It never drafts,
verifies or seeds a carry, and its history is released once its prompt
Expand Down
4 changes: 2 additions & 2 deletions docs/provider/direct-mode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The local API: an OpenAI-compatible server on your Mac

> Last updated: 2026-11-12
> Last updated: 2026-11-13

Your Mac's models as an OpenAI-compatible HTTP server for your own tools,
served two ways: **Both**, the default (`darkbloom start`: beside the Darkbloom
Expand Down Expand Up @@ -660,7 +660,7 @@ frame-timestamp label.
| `enable_thinking` absent or `true` | Template default; `reasoning_content` streams until `</think>` |
| `enable_thinking: false` | All output is `content`, including literal markers |
| `chat_template_kwargs.force_nonempty_content` | Unterminated reasoning becomes `content`: moved in a complete response; a stream sends it as reasoning, then repeats it as `content` at the end |
| `tools`, `tool_choice`, `parallel_tool_calls` (text, image or video) | `<tool_call>` frames become validated `tool_calls`; violations return 422, or end a stream with an error event |
| `tools`, `tool_choice`, `parallel_tool_calls` (text, image or video) | `<tool_call>` frames become validated `tool_calls` (with `parallel_tool_calls: false`, the first one only); violations return 422, or end a stream with an error event |
| `response_format` `json_object`/`json_schema` (text, image or video) | Content is withheld and validated; invalid JSON returns 422, or ends a stream with an error event. With `tools`, calls return as `tool_calls` and only an answer without calls must be JSON |
| `logprobs: true`, `top_logprobs` 0 to 20 (text, image or video) | `choices[0].logprobs.content`, streamed and complete: one entry per generated token in generation order, covering reasoning, answer and tool-call tokens (as vLLM and SGLang return them), each with at least one alternative. Joined, the entry tokens spell the reasoning, the `</think>` marker and then the answer, not the answer alone. Reasoning chunks carry their tokens' entries, and a response that ends while reasoning still carries them. A complete response carries the stream's entries. Tool-call tokens lack entries only in the rare case that nothing follows the call. The request does not speculate; others keep speculating ([logprob rows](../architecture/inference.md#nemotron-super-logprobs)) |
| Contradictory controls, `top_logprobs` outside 0 to 20, `logit_bias`, `min_p` other than 0, `n > 1`, `prompt_cache_key` (text, image or video) | 400 `Invalid inference request.` before generation |
Expand Down
Loading
Loading