Case file: PR #686 — docs(api): document DeepSeek V4/V4.1 behavior for tool_choice required
https://github.com/NVIDIA/hyperflare-inference/pull/686 · open, ready for review, opened 2026-12-02, head 6a2cacc, base c513e46 (main) · +14/−8 in 1 file · no labels, no reviews, no CI checks.
Key findings
- The change is accurate. Every sentence of the new paragraph was checked against the implementation and the two tests the description names:
renders_tool_choicereturns true only forDeepseekV4/DeepseekV41(helios/src/frontend/mod.rs:151-156), shared lowering is its negation (helios/src/server/request.rs:465-476), the thinking-mode downgrade ishelios/src/frontend/deepseek.rs:272-280, the DSML-envelope start is asserted athelios/tests/deepseek_requests.rs:348-415, the identical-to-auto thinking prompt athelios/tests/deepseek_requests.rs:690-711, and completion validation athelios/src/server/protocol/encode.rs:685-689plus undeclared-name rejection at:582-584. - Undeclared gap:
docs/core-design.md:1727-1728keeps the old, unconditional claim — "tool_choice=requiredadds a prompt instruction and requires a completed call to a declared tool." The PR touches onlydocs/api.md, so after it merges the design document still states the thing this PR is correcting, and :1732 defers details to api.md. A reader of core-design.md keeps the original inaccurate statement. - "Fixes #445" closes an issue whose primary request was declined. #445 asked for either required-mode to be passed through to the encoder or the shared instruction to be kept; yatesdr's triage (the issue's only comment, 2026-11-21) called that behavior deliberate and said "the gap is in the docs… The docs should say so." #686 implements only the docs half, so merging closes an issue whose "Expected" paragraph — required should prompt differently from auto — remains unmet and is recorded nowhere except this new paragraph.
- The change is one hunk plus an undeclared rewrap. The same hunk re-wraps the adjacent Responses custom-tools lines (
docs/api.mdmain :673-675 → head :679-681) with no text change. Nothing else in the repo changed; the PR description claims exactly this scope. - No process signal yet. No reviews, no comments, no labels, no reactions, and no CI checks on head
6a2cacceven though.github/workflows/native-serving.yml(not opened) triggers on everypull_request(no path filter). Author declares "no build, test suite, or GPU execution was run" — harmless for a prose-only diff. - Overlap is file-level only. Open #461 (same author, adjacent named/required paragraph, currently CHANGES_REQUESTED) and open #685 (different region of api.md) both edit
docs/api.md; none conflicts textually with this hunk.
1. The change, in plain terms
Single hunk in docs/api.md, section "Conversation and tool semantics" (heading at :485), required-mode paragraph.
Before (main, docs/api.md:666-669): "Required mode needs at least one declared tool, adds an instruction to call a tool to the prompt, and validates that generation produced at least one completed call to a declared tool."
After (PR head, docs/api.md:666-678), four statements:
- "Required mode needs at least one declared tool." (:666-667)
- "Prompt encoders using shared lowering (Jinja templates and TMLv0) add a system instruction to call a tool to the prompt." (:667-668)
- "The native DeepSeek V4 and V4.1 prompt encoders omit that shared instruction: in thinking mode they render required mode identically to
"auto"so reasoning starts in<think>, and in non-thinking (chat) mode their template opens the DSML tool-call block at the end of the prompt so generation starts inside the tool-call envelope." (:668-672) - "In all modes, including DeepSeek thinking mode, completion validates that generation produced at least one completed call to a declared tool." (:672-674)
Not declared in the description: the same hunk re-wraps docs/api.md main :673-675 → head :679-681 ("Responses also supports text custom tools …"), byte-identical text. No other hunk, no code, schema, test or compatibility change (pr_diff). The description declares the correct scope, and it follows the AGENTS.md four-part template (why / what / expected result / evidence + limitation).
2. Why: the problem, in history
- Issue #445 (shieldstar, opened 2026-11-21, label
area:api, still open):tool_choice: "required"is "dropped" on DeepSeek V4/V4.1 in thinking mode — the server seesrenders_tool_choice() == true, stops sending shared instruction messages, and passesToolChoice::Auto. The issue citesrequest.rs:336,:341-345,inference.rs:378-380,frontend/mod.rs:154-156,docs/api.md:493-495at commit25b49519. - Maintainer triage, same day, 12 minutes later (yatesdr, 2026-11-21 18:38, the issue's only comment), at main
21a40f05: "For DeepSeek V4 and V4.1 this is deliberate, and the gap is in the docs." It points athelios/src/frontend/deepseek.rs:275-280("Required calls are checked at completion"),tests/deepseek_requests.rs:690,Encoder::finishfailing with "required tool choice was not satisfied", and saysdocs/api.md:537-540"says required mode 'adds an instruction to call a tool to the prompt', which is not true for these recipes. The docs should say so." - Origin of the behavior: commit
585702d3(Luke Alonso, 2026-10-29) "Allow required DeepSeek tool choices with thinking" introduced the downgrade; the native DeepSeek encoders came from2a4fcb9f(2026-10-19) andac7bfa9a(2026-10-29). - Timeline: behavior deliberately introduced 2026-10-29, reported 2026-11-21, triaged as a docs gap the same day, doc PR opened 2026-12-02 — 11 days after triage, 34 days after the behavior shipped. Interest is one maintainer's written request plus one contributor acting on it; there is no broader demand trail in the tracker.
3. Claims and evidence
Everything in the description checks out; nothing claimed is unbacked.
| Claim | Evidence |
|---|---|
renders_tool_choice true for V4/V4.1, bypassing shared lowering in template_inputs |
helios/src/frontend/mod.rs:151-156 (matches only `DeepseekV4 |
Thinking mode renders identical to "auto", reasoning starts in <think> |
helios/src/frontend/deepseek.rs:272-280 (required with no tools errors; Required → Auto only when thinking_mode, comment "Required calls are checked at completion; thinking starts before the tool block"); test helios/tests/deepseek_requests.rs:690-711 asserts required.rendered_prompt == automatic.rendered_prompt, equal tokens, OutputStart::Reasoning, prompt ends <|Assistant|><think>, for V4 and V4.1 across {}, {enable_thinking:true}, {thinking_mode:"thinking"}, plus required-with-empty-tools error |
Non-thinking (chat) mode opens the DSML block at the end of the prompt |
helios/tests/deepseek_requests.rs:348-415: OutputStart::ToolBody; prompt trim_end() ends <|DSML|tool_calls> (V4) / <|DSML| calls> (V41); grammar present; required rejects an ordinary {"ok":true} answer while an auto control accepts text. Detection at helios/src/model/prompt.rs:357-371 |
| Shared-lowering encoders (Jinja, TMLv0) add a system instruction | helios/src/server/inference.rs:387-390 appends "You must call at least one of the provided tools in your next response…" for ToolChoice::Required via append_system_instruction (:445-462); TMLv0 has a system frame kind (helios/src/frontend/tml.rs:424-425) |
| Completion validates a completed declared call in all modes | helios/src/server/protocol/encode.rs:685-689 errors "required tool choice was not satisfied: the model did not produce a completed tool call" for `Required |
| "No runtime code, schemas, or compatibility contracts changed" | Verified: one file, prose only |
| Limitation: no build/test/GPU run | Declared by the author; nothing in the diff can affect compilation or runtime. Comparable docs PR #461 ran only a narrow lib grammar test |
Not demonstrated anywhere: end-to-end qualification of the TMLv0 half of the first new sentence — docs/TODO.txt:12-15 still tracks qualifying strict: true tools on a TMLv0 core. Pre-existing, inherited by naming TMLv0 explicitly.
4. Related work
- #461 (jcartu, open since 2026-11-22, labels
area:api/documentation/triage:review, +88/−26 overdocs/api.md,docs/TODO.txt,helios/src/grammar/strict.rs(not opened)): edits the adjacent named/required selection sentences (docs/api.md:649-655region) — required mode "adds no decoding constraint", strict-schema admission, IEEE-754 range text. It has a CHANGES_REQUESTED review from yatesdr (2026-11-23) and an Autobot review (2026-11-24, 4 should-fix items), unanswered since jcartu's 2026-11-28 reply. So #686 is the same author's second docs PR in the same section while the first is still blocked; if both land the required-mode contract is described across two separately-written paragraphs. - #685 (peperunas, first-time contributor, open 2026-12-02, 13 files, +662/−72): rewrites the DSML-streaming part of
docs/api.md(~:540-575) andhelios/src/output/dsml.rs(not opened),server/output.rs(not opened). Different region, no conflict; same "Conversation and tool semantics" section. - Orientation-packet candidates #578 (deepseek-recipe bump for aborted DSML parameter openers), #637 (37-char tool-call IDs), #615 (
thinking_token_budget), #670 (THINK_TAGS/TAGGED_JSON), #621 (jcartu, scheduler admission) sharedocs/api.mdonly, not this paragraph. None competes with, is superseded by, or undoes #686. - The sentence immediately above the hunk (
docs/api.md:663-666, DeepSeekstring="false"retention, typed XTML) is the #359/#364/#578 lineage and is left intact. - Author's closed DeepSeek-adjacent proposal #404 (optional per-request activation steering for DeepSeek V4.1 cores) was closed, i.e. prior DeepSeek-specific proposals from this author did not merge.
5. Recent activity in the touched area
docs/api.md changed almost daily in the ten days before the branch point, and #686 builds on that text rather than conflicting with it:
2acc3f3a#670 (Luke Alonso, 2026-12-02) THINK_TAGS parameterization + TAGGED_JSON parser, api.md edits from ~:586 — newest main commit before the branch.cd1daa3e#638 (2026-12-01) Responses tools /text.formatecho;4ed5d875#637 (2026-11-30) 37-char call IDs — both rewrite text in this section.92a5b888#578 (Allyn Malventano, 2026-11-29) deepseek-recipe bump;2bdc8472#573 (Luke Alonso, 2026-11-28) tagged-parser EOS tolerance — neighbours of the hunk.0b09434d#418 (jcartu, 2026-11-22) strict function-tool schemas — this author's earlier edit of the same tool block.
DeepSeek frontend: no commit to helios/src/frontend/deepseek.rs since 71fed07b (yatesdr, 2026-11-19); the required/thinking downgrade is untouched since 585702d3 (2026-10-29). The documented behavior has been stable for over a month. Nothing recent conflicts with, reverses, or supersedes #686, and by the orientation packet no main commits since the branch point (c513e46) touch docs/api.md, so no rebase is needed.
6. People
- Author: jcartu, association CONTRIBUTOR; last 180 days 3 merged, 3 closed, 3 open. Merged: #505 (bind core-declared FP32 parameters into text forward graphs), #416 (refresh host prefix-cache recency on completion), #418 (strict function-tool schemas for DSML/Qwen/GLM/TML). Areas: docs (3),
helios/src(3),heliopause/src(1),helios(1),helios/proto(1). #418 is the direct precursor and, with #461, makes this the third pass over required-mode semantics in api.md. - Open siblings: #461 (docs, changes requested), #621 (scheduler admission vs core parameter declarations), #642 (ignition relocate_inductor).
- Area owners: docs commits in 180 days — Luke Alonso (391), Martin Vit (55), yatesdr (49). The DeepSeek frontend is Luke Alonso's (
2a4fcb9f,ac7bfa9a,585702d3) and Martin Vit's for tool parsing (#359, #364). - Reviewer-of-record: yatesdr triaged #445 and wrote "The docs should say so", but has not commented on #686 and has not been requested. No one else has engaged.
7. Community
Nothing organic. Zero comments, zero reviews, zero reactions, no linked discussion; the only engagement in the chain is yatesdr's pre-existing triage comment on #445. Autobot has not posted a case file on #686 (unlike #685 and #461, each of which got one shortly after opening), consistent with the PR having had no automated or human traffic.
8. Project fit (charter and repo rules)
- Lines up: charter line 35 — "What gets merged: PRs that address a maintainer request, a roadmap item, a reproducible bug, a measured performance/memory issue, or bad docs." #686 corrects documentation a maintainer explicitly called "not true for these recipes", open issue label
area:api. AGENTS.md also accepts inaccurate documentation as sufficient basis. - Lines up (prose rules): the text describes implemented behavior, so no "designed, not implemented" marker is needed; it is not being logged as an unresolved defect in
docs/TODO.txt, correctly, since yatesdr called the behavior designed rather than a defect. - Tension: the "#417 never silently drop API fields" rule is what made #445 read as a violation — the server accepts
requiredand adds no prompt instruction. The maintainer's counter is that the requirement is enforced at completion (encode.rs:685-689), so the field is not dropped, only lowered differently. #686 documents that reconciliation; it changes no invariant. - Tension (pre-existing): the charter's "keep the runtime model-agnostic / no per-model special cases" line. #686 documents an existing per-encoder branch (
renders_tool_choice) as intended behavior; a reviewer who objects to the branch itself would object to enshrining it in docs, but that branch predates this PR (585702d3). - Compatibility: the description says none changed and the diff confirms it.
9. File map and conflicting text
docs/api.md, section "Conversation and tool semantics":
- :640-647 supported tools and
tool_choicespellings per protocol. - :649-655 named selection ("adding no instructions or decoding constraints"; "Missing and incomplete calls fail as in required mode") — #461 edits here, #686 does not.
- :657-666 auto mode, undeclared-tool passthrough, tagged-parameter retention, DeepSeek
string="false". - :666-678 (head) / :666-669 (main) — the required-mode paragraph, the only hunk.
- :679-685 Responses custom tools / namespaces (rewrapped, unchanged).
- :687-692 Lark/regex grammars; :694-708
parallel_tool_calls. - Consistent elsewhere: :759-760 ("A required or named tool choice still fails if no qualifying call completed"); :980-981 (DeepSeek V4/V4.1 default to thinking enabled and high effort); :1005-1006 (both native encoders reject
drop_thinking, assistant continuation,add_generation_prompt=false). - Contradicting elsewhere:
docs/core-design.md:1727-1728— old unconditional sentence, untouched by this PR; :1732 defers to api.md.
10. Reach
- Clients of cores using
PromptEncoder::DeepseekV4/DeepseekV41that sendtool_choice:"required". Because these recipes default to thinking enabled (docs/api.md:980-981), the "thinking mode" caveat is the default case, not an edge case: the model gets no must-call instruction and a required request can end as HTTP 500 / terminal error event ("required tool choice was not satisfied") instead of a tool call. chatmode is reachable via nativethinking_mode:"chat"orenable_thinking:false(helios/src/frontend/deepseek.rs:181-190); api.md:1005-1006 lists what those encoders reject but not the accepted spellings for disabling thinking. In chat mode required and auto now produce different prefixes (required starts inside the DSML envelope), so they would not share a prefix-cache entry there, while in thinking mode they render identically and do share one — a detail the new paragraph implies but does not spell out.- Jinja/TMLv0 cores (Qwen, GLM, Kimi, Inkling 2, MiMo, Nemotron…) are behaviorally unaffected; only the wording now names them.
- No configuration, default, schema, wire format, dependency or migration change. Docs-only.
11. Process
Open and marked ready for review (not draft). No CI checks on head 6a2cacc even though .github/workflows/native-serving.yml (not opened) triggers on every pull_request and has no path filter — a docs-only PR would run the whole release-CLI build and helios test target on Linux and Windows, but nothing has started. Branch is current (no main commits touching docs/api.md since c513e46). Prose conforms to the file's ~78-80 column wrapping and present tense, and names the encoders in prose ("DeepSeek V4 and V4.1") rather than by enum spelling. Age at review: under a day.
Open questions / not found
- Does the maintainer who requested this (yatesdr) intend
Fixes #445to close an issue whose behavioral half was declined? No maintainer comment on #686 addresses it; nothing in the tracker records the decline except the new paragraph. - Will
docs/core-design.md:1727-1728be corrected in a follow-up, or is the divergence accepted? No open PR or issue does it. - No test evidence was produced on this branch (declared); no rendered-markdown check exists.
- Coordination with #461 is unstated: which of the two paragraphs will describe required mode if both merge, and does #461's "adds no decoding constraint" wording interact with this text? No cross-reference between the two PRs.