Repository navigation
Render an earlier tool call's null arguments; serve those requests cold - #2651
Merged
Merged
Conversation
The call parser converted argument text with the render types the ingress repair writes for the chat template, so a union, `not` or if/then/else parameter read as its first or default member: under `oneOf: [integer, number]` the text "2.5" stayed a string, which the declaration refuses. The parser and the Qwen strict grammar's reading now use each tool's parameters as sent (`Prepared.argumentTools`, `ToolArgumentSchemas`), with a typeless enum/const node typed by its own values, which accepts the same instances. The template still renders the repaired declarations; auto validation already read the declarations as sent. GLM is unchanged. Tests cover the tool-call schema fuzz grid constructs: the reading accepts exactly the declared instances, the rendered parameter keeps its render type, and Qwen 3.5 calls parse to arguments their declaration accepts.
With reasoning on, Lightning sometimes closes its thought early to sketch the calls it plans, keeps reasoning in plain text, closes the thought again and then writes the real calls. The splitter absorbs the second </think> as a stray close and keeps everything before it as content, so the sketched frames were parsed as calls too: two parallel calls came back as four. On the Nemotron route (absorbStrayThinkClose with the nemotron parser), the splitter now holds content from the first tool frame after a closed thought. A stray </think> turns the held text into reasoning, so its frames never become calls; at the end of the output the held text is content as before. Calls are not deduplicated by value, since identical parallel calls can be intended.
…d tool-call arguments with the caller's declarations
…draft calls before a second thought close as reasoning
A JSON null in an earlier assistant tool call's arguments was dropped before
the chat template rendered, so the model saw a different call than the one it
made (Gemma 4: call:clear_project_deadline{} for {"deadline": null}) and
repeated the omission. The shared sanitizer now keeps those nulls as Jinja
null at their key or array position (sanitizeMessageForJinja, and Gemma 4's
string-argument path). Gemma 4's format_argument macro and the Qwen 3.5 /
Nemotron 3.5 Lightning XML parameter value gain a branch that writes null;
the rewrite is applied by the serving tokenizer and the render check only, so
the managed Nemotron Super contract renders as before. Tool parameter schemas
keep the drop policy. GLM-5.3, MiMo and Flint already kept these nulls.
The prompt contract stays darkbloom-request-normalization-v9, which still
renders such a call without its nulls. A coordinator request whose tool-call
history carries one, on a model that renders through the shared sanitizer, is
served without the prompt cache: no scope or receipt nonce, so no lookup or
ready receipt, no cached-token usage and no checkpoint write. The template
controls still come from the planned context. Each such request is logged
(public fixed line) and counted in the daemon state
(promptCacheSkippedToolCallNull).
ProductionPromptParityTests classifies a vector body with a history null as
provider-rendered and uncacheable: it checks that the body is served cold and
that the vectors still match the same body with those nulls dropped; the
vectors are unchanged. Guards updated because they asserted exactly the old
drop: JinjaSanitizationTests (the null unit argument stays Jinja null),
Gemma4ToolCallArgumentsTests (a parsed null leaf becomes Jinja null) and
FlintTemplateReplayTests' generic-architecture case (call arguments keep their
nulls; its schema assertions are unchanged).
4 of 13 tasks
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
7 of 15 tasks
… pin the 14 cases ProductionPromptParityTests now classifies a vector body as provider-rendered by ToolCallHistoryNullCache.servingContext itself (the serving decision), builds the v9 body for the vector comparison by passing each history call's arguments through the production sanitizeForJinja instead of a test-only dropper, and requires the classified set to be exactly the 14 vector bodies (7 models x endpoint_messages_tool_turn and gemma_tool_turn) whose earlier call carries a null. Every other case is checked as before; the vectors are unchanged.
MiMoV26PromptContractTests.testOtherFamilyStillUsesExistingPermissiveControlAndNullNormalization rendered a MiMo reference body through another family's normalization and expected different tokens, because the shared sanitizer dropped the nulls in that body's earlier call arguments. Those are exactly the nulls it now keeps, as MiMo always has, so the two renders agree. The assertion now requires that agreement; the malformed-control half of the test is unchanged, and MiMo's own render is still pinned by the reference corpus.
…ps a null Adds a second body to testOtherFamilyStillUsesExistingPermissiveControlAndNullNormalization with a null outside any call's arguments (a tool parameter schema's default), which the shared sanitizer still drops and MiMo keeps. The other family's render of it must still differ from MiMo's. The arguments-only reference body keeps the agreement assertion from the previous commit.
The schema body now renders twice per family: without the default null the two families must render it alike, and with the default null they must differ, so the null is the only cause of the difference. The schema value is typed as MLXLMCommon.JSONValue explicitly.
This was referenced Nov 24, 2026
Closed
This branch was successfully deployed
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.
Summary
An earlier assistant tool call's JSON
nullarguments now reach the model asnullat their key or array position. Before, they were dropped, so the model saw{}for{"deadline": null}and repeated the omission.The prompt contract stays
darkbloom-request-normalization-v9, which still renders such calls without their nulls. A coordinator request whose tool-call history carries one is therefore served without the prompt cache: no lookup, no receipt, no cached-token usage and no checkpoint write. Every other request is unchanged.Linked issue
None.
Base
Until the C7 candidate lands on
dev, this PR is based on the C7 candidate head9bd3e01f7d(release/0.10.18-c7-candidate-3), so its diff againstdevalso shows the C7 changes. This PR's change is commits194b8d2404(the change),bf0385b9a5(parity classification)808a6b53cd,96fb1569c8and3e550134aa(MiMo other-family guard). Once C7 lands,devis merged in with a signed merge commit (no rebase, no force). This replaces #2649, which was based on an earlier C7 candidate.What changes
sanitizeMessageForJinja(ProviderCoreFoundation) drops null leaves as before, except inside each tool call's decodedfunction.arguments, where they become Jinjanull. Object keys are kept and array positions stay uncompacted. Gemma 4's string-argument path does the same.renderingToolArgumentNullsadds anullbranch to Gemma 4'sformat_argumentmacro and to the Qwen 3.5 / Nemotron 3.5 Lightning XML parameter value.LocalTokenizerLoader) and by the render check only. The managed Nemotron Super contract, which usesnormalizeSwiftJinjaTemplatedirectly, renders as before.tojson, so they print the null without a template change.ToolCallHistoryNullCache):prefix_cache_lookup_v2and noprefix_cache_ready_v2. The engine runs with caching disabled, and terminal usage carries no cache fields.Prompt cache skipped: an earlier tool call has a null argument; served coldtodarkbloom logs.AtomicProviderStatsand written to the daemon state asstats.promptCacheSkippedToolCallNull.Test plan
CI (dev) on this head.
ProviderCoreFoundation test target, built locally as a standalone package (no MLX):
PromptContractIdentityTestspasses, so the v9 vectors are unchanged.Every shipped chat template, checked locally against copies matching the manifest
sha256(not committed): Gemma 4 QAT and 8-bit, Qwen 3.5 9B and 35B, Qwen 3.6, Qwen 3.8, Nemotron 3.5 Lightning and GPT-OSS.deadline:null,flags:{dark-mode:null},…,payload:{data:[null,{}]},rows:[[false,<|"|>Total<|"|>],null].New tests:
ToolArgumentNullRenderTests(ProviderCoreFoundation): sanitizer; verbatim served blocks for Gemma 4, Qwen 3.5 XML, Nemotron 3.5 Lightning, Qwen 3.6 / 3.8tojson, GPT-OSS and Inkling 2; null detection; null-free bytes; rewrite idempotence; plain normalization keeps the Super path unchanged.ToolCallHistoryNullCacheTests(ProviderCore):ProductionPromptParityTests: the shared vectors are not changed or regenerated.Production classifier: a vector body is classified as provider-rendered and uncacheable by the serving decision itself,
ToolCallHistoryNullCache.servingContext(carriesNullplusrendersThroughSharedSanitizer).Pinned set: the classified set must be exactly the 14 vector bodies whose earlier call carries a null (7 models ×
endpoint_messages_tool_turnandgemma_tool_turn). One more or one fewer fails the test.For each classified body, the test checks that:
sanitizeForJinja.On all 14 bodies that drop is byte-equal to a hand-written v9 drop (checked locally).
Other cases: every other case is checked exactly as before.
Guards updated because they asserted exactly the old drop:
JinjaSanitizationTests: the nullunitargument stays Jinja null.Gemma4ToolCallArgumentsTests: a parsed null leaf becomes Jinja null.FlintTemplateReplayTestsgeneric-architecture case: call arguments keep their nulls; its schema assertions are unchanged.Also
MiMoV26PromptContractTests.testOtherFamilyStillUsesExistingPermissiveControlAndNullNormalization: it expected another family's render of a MiMo reference body to differ, because the shared sanitizer dropped that body's call-argument nulls. Those nulls are now kept, as MiMo always has, so for that arguments-only body the assertion now requires the renders to agree. A second body, with a null outside call arguments (a tool parameter schema'sdefault, which the shared sanitizer still drops and MiMo keeps), is rendered twice per family: without the null the two families must render it alike, and with it they must differ. The null is therefore the only cause of the difference, and the guard keeps protecting MiMo from the other family's null removal. Its malformed-control half is unchanged. Each edit changes only the assertion about the old null-dropping, and the reason is given next to each guard above; nothing was re-baselined. The Nemotron Super golden tests and the other MiMo tests are unedited.Red control: Red control for #2651: tests without the change (do not merge) #2652. It keeps the new API so the tests compile, but restores the old drop and never serves cold. Locally, ProviderCoreFoundation fails at exactly the new
ToolArgumentNullRenderTestscases and nothing else.Components touched
Protocol / interface changes
Documentation impact
docs/architecture/inference.md(null rendering),docs/architecture/prefix-cache.md(served cold),docs/architecture/model-registry.md(render check feeds templates like the serving tokenizer).Changelog
changelog.d/tool-call-history-nulls.mdand ranpython3 scripts/changelog.py check.Notes
request_exceeds_context400, which carries no health effect, and then moves on to the rest of the fleet.Before And After
Before:
flowchart LR A["history call arguments<br/>{deadline: null}"] --> S["sanitizer drops null"] --> T["template renders<br/>call:f{}"] --> M["model repeats {}"] P["coordinator plan (v9)"] --> C["cache lookup + receipts<br/>prompt matches plan"]After:
flowchart LR A["history call arguments<br/>{deadline: null}"] --> S["sanitizeMessageForJinja keeps null"] --> T["template renders<br/>call:f{deadline:null}"] --> M["model sees the real call"] P["coordinator plan (v9)"] --> D{"history null and<br/>shared sanitizer?"} D -- no --> C["cache lookup + receipts as before"] D -- yes --> X["no scope, no receipt nonce:<br/>served cold, logged, counted"]Code flow (inference handler):
Refactor Pass
Refactor pass: done; comment fix deferred unless head moves.