Review — PR #686, lens: Correctness, Contracts & System-Level Consequences
docs(api.md): document DeepSeek V4/V4.1 behavior for tool_choice: "required" — head 6a2cacc, base c513e46, +14/−8 in one file (docs/api.md).
Key findings
- Major — the same false sentence the PR corrects is left standing in
docs/core-design.md:1727-1729.docs/core-design.md:1727still reads "tool_choice=requiredadds a prompt instruction and requires a completed call to a declared tool", unconditionally, and:1732only defers toapi.mdat file level. After merge the two normative docs contradict each other, and half of the gap yatesdr's #445 triage asked for ("The docs should say so") remains open whileFixes #445closes the issue. - Minor — "they render required mode identically to
"auto"" (docs/api.md:669-670) is prompt-identity, not behavior-identity. With astrict: truetool the request still forces a tool call during decoding:require_callis derived from the server-sideToolChoice::Required(helios/src/server/request.rs:277-281), which masks plain prose (helios/src/grammar/strict.rs:1829-1835), and the in-repo test asserts exactly that on the default thinking path (helios/tests/deepseek_requests.rs:815). One qualifying clause would prevent misreading. - Every factual claim in the new paragraph and in the PR description is accurate — verified against
renders_tool_choice,template_inputs,template_messages, the DeepSeek frontend downgrade,Encoder::finish, and the two named tests. No inaccurate before/after claim. - No system-level consequences are possible. The diff is prose only: no runtime, wire/proto, captured-graph, admission, scheduler, metric/rate, buffer or cache path is touched, so the concurrency/contention, memory-amplification, failure-blast-radius, metric-span and Unix/Windows parity checks come back clean by construction. No owner sign-off is required for a docs correction under charter line 35 ("bad docs").
1. Major — docs/core-design.md keeps the unconditional claim (contract divergence)
Severity: Major. File: docs/core-design.md:1727-1733 (unchanged by this PR; the diff touches docs/api.md only).
Verbatim, at PR head:
1727 `tool_choice=required` adds a prompt instruction and requires a completed call
1728 to a declared tool. Without a grammar it uses ordinary sampling. Named tool
1729 selection filters the definitions to that tool; it does not by itself enable a
1730 grammar.
Contrast with the paragraph this PR writes, docs/api.md:667-674:
Prompt encoders using shared lowering (Jinja templates and TMLv0) add a
system instruction to call a tool to the prompt. The native DeepSeek V4 and V4.1
prompt encoders omit that shared instruction: ...
... In all
modes, including DeepSeek thinking mode, completion validates that generation
produced at least one completed call to a declared tool.
docs/core-design.md:1732-1733 says only "See the API contracts for the accepted strict schema subset, parser formats, protocol mappings and streamed errors" — a file-level pointer, not a pointer to the required-mode paragraph, so nothing in core-design.md rescinds its own unconditional statement.
Implementation confirms the api.md side and refutes the core-design side: helios/src/frontend/mod.rs:154-156 (renders_tool_choice true only for DeepseekV4 | DeepseekV41), helios/src/server/request.rs:465-476 (shared_lowering = !frontend.prompt_encoder().renders_tool_choice(); non-shared encoders get ToolChoice::Auto for the messages), and helios/src/server/inference.rs:387-390 (the instruction is appended only inside template_messages, i.e. only on the shared-lowering path).
Impact: the PR exists to make the docs say that required mode does not always add a prompt instruction. A reader who lands on core-design.md — the document AGENTS.md routes runtime/frontend questions to, and the one that carries the request-grammar contract this paragraph sits in — keeps the original inaccuracy after this PR merges, and Fixes #445 will close the issue with the docs half only partly done. The DeepSeek default is thinking-enabled, so this is the common path, not an edge case.
Fix (in this PR, scope already docs-only): rewrite core-design.md:1727 to separate the two halves, e.g. "tool_choice=required requires a completed call to a declared tool; shared-lowering prompt encoders (Jinja templates and TMLv0) also add a prompt instruction, while the native DeepSeek V4/V4.1 encoders do not." Alternatively drop the instruction half at :1727 and replace the file-level link at :1732 with a link to api.md's required-mode paragraph.
2. Minor — "render identically to "auto"" overstates the equivalence for strict tools
Severity: Minor (wording precision; no false statement about prompt rendering). File: docs/api.md:668-672.
Verbatim:
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.
The prompt is indeed identical (downgrade at helios/src/frontend/deepseek.rs:276-280, the Required → Auto swap happens in frontend option parsing only; asserted by helios/tests/deepseek_requests.rs:697-703). But the request grammar is not: the server-side request.tool_choice is still Required when the plan is built —
helios/src/server/request.rs:277-281
allow_undeclared: request.tool_choice == ToolChoice::Auto,
require_call: matches!(
request.tool_choice,
ToolChoice::Required | ToolChoice::Named(_)
),
and helios/src/grammar/strict.rs:1829-1835 makes the body branches "tools_entry" whenever plan.require_call, so prose is masked out. The in-repo test shows the observable difference on the default (thinking) path, helios/tests/deepseek_requests.rs:810-816:
let req_single = json!({
"tools": tools,
"tool_choice": "required",
"parallel_tool_calls": false
});
assert!(!f.accepts(req_single.clone(), "Thinking.</think>Just text."));
while the auto control at helios/tests/deepseek_requests.rs:774 accepts the same plain prose.
The same concern touches the retained sentence at docs/api.md:674 — "Sampling is unchanged; no calls are fabricated and no retries are attempted" — which is also pre-existing on main and reads oddly next to a grammar that, under require_call, does change what can be sampled.
Impact: limited to cores with strict: true tools, but there a reader could conclude required and auto are behaviorally interchangeable in thinking mode, when constrained sampling still forces a declared call before completion validation even runs.
Fix: qualify the clause, e.g. "in thinking mode they render the same prompt as "auto" (reasoning starts in <think>); a strict tool still constrains sampling so only a declared tool call can follow reasoning."
3. Accuracy of the change — verified sound
Severity: none. All statements traced at head:
renders_tool_choicetrue only for the two DeepSeek encoders —helios/src/frontend/mod.rs:151-156.- "shared lowering (Jinja templates and TMLv0)" is exactly the complement —
helios/src/server/request.rs:467plusToolChoice::Autosubstitution at:472-476;"required"still reaches template options at:506-514. - shared instruction text —
helios/src/server/inference.rs:387-390: "You must call at least one of the provided tools in your next response…". - thinking-mode downgrade and its comment —
helios/src/frontend/deepseek.rs:275-280: "Required calls are checked at completion; thinking starts before the tool block." - thinking prompt identical to auto, ending
<|Assistant|><think>, for V4 and V4.1 across{},{enable_thinking:true},{thinking_mode:"thinking"}—helios/tests/deepseek_requests.rs:690-711. chatmode opening the DSML block —helios/tests/deepseek_requests.rs:348-415(OutputStart::ToolBody; prompt ends<|DSML|tool_calls>/<|DSML| calls>), detection athelios/src/model/prompt.rs:357-371;chatspelling reachable viathinking_mode:"chat"/enable_thinking:false(helios/src/frontend/deepseek.rs:181-190).- completion validation in all modes, including thinking —
helios/src/server/protocol/encode.rs:685-689("required tool choice was not satisfied: the model did not produce a completed tool call"), undeclared names rejected at:582-584. - "Required mode needs at least one declared tool" —
helios/src/frontend/deepseek.rs:272-274errors when required has no tools.
The PR description's before/after quotes match docs/api.md main :666-669 versus head :666-678, and its "no runtime code, schemas, or compatibility contracts changed" claim matches the diff exactly.
4. System-level effects, concurrency, resources, metrics, platforms — clean
The only changed file is docs/api.md (pr_diff). No lock, queue, admission, scheduler, buffer, cache, checkpoint or serialization path is touched; no metric or rate definition changes scope, so there is no span shrink to trace. No code means no Unix/Windows parity exposure, no panic/error-handling surface, no stale-state-across-reset concern. Failure-propagation blast radius is unchanged: a required-mode DeepSeek thinking request that produces no call still fails at encode.rs:685-689 → HTTP 500 / terminal error event, exactly as docs/api.md:675-678 now describes.
5. Tests, process and claim accuracy
- No test needed and none missing: prose-only diff; the behavior it documents is already covered by
helios/tests/deepseek_requests.rs:348-415and:690-711plus:810-816. The author's declared "no build, test suite, or GPU execution was run" limitation is honest and harmless here. - No CI checks started on head
6a2cacc, which is consistent with a docs-only diff; nothing in the diff can affect compilation. - Undeclared but harmless rewrap: the same hunk re-wraps
docs/api.mdmain :673-675 → head :679-681 ("Responses also supports text custom tools…") with byte-identical text. Worth a one-line mention in the description, not a blocker. - Interaction with open #461 (same author, adjacent named/required paragraph, currently CHANGES_REQUESTED): no textual conflict with this hunk, but if both land, required-mode semantics are described across two independently written paragraphs. Worth coordinating in one place.
Open questions / not verified
- Does yatesdr intend
Fixes #445to close an issue whose behavioral request (make required prompt differently fromauto) was declined? If so, the closing comment should point atdocs/api.md:667-674anddocs/core-design.md:1727so the decline is recorded where the issue tracker can see it. I did not open #445 directly in this pass; this rests on the PR body and the triage quoted in the discovery dossier. - Will
docs/core-design.md:1727be corrected in a follow-up or accepted as divergent? No open PR or issue currently does it, so unless it is fixed here the inaccuracy survives.