Skip to content

docs: document DeepSeek V4/V4.1 behavior for tool_choice required - #686

Merged
lukealonso merged 1 commit into
NVIDIA:mainfrom
jcartu:docs/deepseek-required-tool-choice
Dec 4, 2026
Merged

lukealonso merged 1 commit into
NVIDIA:mainfrom
jcartu:docs/deepseek-required-tool-choice

Conversation

@jcartu

@jcartu jcartu commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #445

Why

Both docs/api.md and docs/core-design.md stated unconditionally that tool_choice: "required" adds a prompt instruction to call a tool. In Helios, only the Jinja-template and TMLv0 prompt encoders receive the server-appended system instruction (PromptEncoder::renders_tool_choice returns false in helios/src/server/request.rs). The native DeepSeek V4 and V4.1 prompt encoders return true from renders_tool_choice and handle required mode in their own syntax: in thinking mode, helios/src/frontend/deepseek.rs passes ToolChoice::Auto so reasoning starts in <think> with no added prompt instruction; in non-thinking mode, the native DeepSeek template opens the DSML tool-call block at the end of the prompt. Updating both specifications aligns the docs with the implemented runtime behavior without adding runtime branches.

What changed

Updated the required-mode descriptions in docs/api.md and docs/core-design.md:

  • Before: docs/api.md stated that required mode adds an instruction to call a tool to the prompt without distinguishing prompt encoders, and docs/core-design.md stated unconditionally that tool_choice=required adds a prompt instruction and requires a completed call to a declared tool.
  • After: docs/api.md states that Jinja-template and TMLv0 prompt encoders add a system instruction to call a tool to the prompt, while the native DeepSeek V4 and V4.1 prompt encoders add none—rendering required mode identically to "auto" in thinking mode (so reasoning starts in <think>) and opening the DSML tool-call block at the end of the prompt in non-thinking mode—and that completion validates at least one completed call to a declared tool across all modes. docs/core-design.md now matches that split and links to docs/api.md#conversation-and-tool-semantics.

No runtime code, wire schemas, or compatibility contracts changed.

Expected result

Callers and contributors reading either docs/api.md or docs/core-design.md receive a consistent, accurate specification of prompt rendering and completion validation for tool_choice: "required" across Jinja-template, TMLv0, and native DeepSeek V4/V4.1 prompt encoders.

Evidence and limitations

Verified each statement directly against the implementation and tests:

  • PromptEncoder::renders_tool_choice (helios/src/frontend/mod.rs)
  • template_inputs (helios/src/server/request.rs) and template_messages (helios/src/server/inference.rs)
  • conversation (helios/src/frontend/deepseek.rs)
  • Encoder::finish (helios/src/server/protocol/encode.rs)
  • required_tools_in_chat_mode_start_inside_the_dsml_envelope and required_and_named_tools_keep_the_thinking_prompt (helios/tests/deepseek_requests.rs)

Limitation: this is a documentation-only change; no build, test suite, or GPU execution was run on this branch.

Discord: jcartu

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 686.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation model:deepseek-v4.1 Affected recipe or documented reproducer: deepseek-v4.1. Impact may be broader. model:deepseek-v4 Affected recipe or documented reproducer: deepseek-v4. Impact may be broader. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The new required-mode prose in docs/api.md is factually accurate against the implementation and tests at 6a2cacc, and has zero runtime blast radius. But docs/core-design.md:1727 still carries the exact unconditional claim this PR exists to fix, so the two normative docs contradict each other while Fixes #445 closes the issue.

  • Blockers: 0 · Should fix: 1 · Subtract/Simplify: 1 · Nits: 0
Walkthrough
  • docs/api.md:666-674: Replaces the unconditional claim that tool_choice: "required" always adds a prompt instruction with an encoder-specific split:
    • Jinja-template and TMLv0 encoders add a system instruction to call a tool (helios/src/frontend/mod.rs:154-156, helios/src/server/request.rs:467-476, helios/src/server/inference.rs:387-390).
    • Native DeepSeek V4 and V4.1 encoders omit that instruction—rendering required mode identically to "auto" in thinking mode so reasoning begins in <think> (helios/src/frontend/deepseek.rs:272-280, helios/tests/deepseek_requests.rs:690-711), and opening the DSML tool-call block at the end of the prompt in non-thinking mode (helios/tests/deepseek_requests.rs:348-415).
    • Completion validation enforces at least one completed call to a declared tool across all modes, including DeepSeek thinking mode (helios/src/server/protocol/encode.rs:582-584, :685-689).
  • docs/api.md:674-681: Reflows the remainder of the same paragraph (unchanged wording for sampling, missing-call errors, and Responses custom tools).
Merge Risk: Low · up to 6a2cacc
  • Documentation-only diff (docs/api.md, +14/−8); no runtime, scheduler, protocol, grammar, schema, or build paths are touched.
  • Zero concurrency, resource, failure-propagation, or cross-platform regression surface.
  • Textual merge conflict exists with open PR Document strict tool selection and numeric range precision #461 on the same required-mode paragraph in docs/api.md (lines 666–678 here vs. lines 562–575 on pr/461); whichever lands second will need a small rebase.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Prose-only change in docs/api.md; no code, links, scripts, or prompt-injection vectors.
  • ✅ Charter & value fit: Directly addresses maintainer triage on tool_choice: "required" is dropped on DeepSeek V4/V4.1 in the default thinking mode #445 ("bad docs" merge criterion) without adding runtime per-model branches.
  • ⚠️ Related / duplicate / conflict check: Not a duplicate, but directly conflicts textually with the author's own open PR Document strict tool selection and numeric range precision #461 (docs/api.md:562-575 on pr/461 edits the same required-mode paragraph); docs/core-design.md:1727 also remains out of sync.
  • ✅ Tests & verification evidence: Every statement was verified against the implementation and existing tests (helios/tests/deepseek_requests.rs:348-415, :690-711); omitting a build/GPU run is declared and acceptable for a docs-only diff.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Both docs/api.md and docs/core-design.md stated unconditionally that
tool_choice: "required" adds a prompt instruction to call a tool. In Helios,
only the Jinja-template and TMLv0 prompt encoders receive the server-appended
system instruction (when PromptEncoder::renders_tool_choice returns false in
helios/src/server/request.rs). The native DeepSeek V4 and V4.1 prompt encoders
return true from renders_tool_choice and handle required mode in their own
syntax: in thinking mode, helios/src/frontend/deepseek.rs converts
ToolChoice::Required to ToolChoice::Auto so reasoning opens in <think> with no
added instruction; in non-thinking mode, the native DeepSeek template opens the
DSML tool-call block at the end of the prompt. Updating both specifications
aligns the documentation with the implemented runtime behavior without adding
runtime complexity.

Updated the required-mode descriptions in docs/api.md and docs/core-design.md.
Before this change, docs/api.md stated that required mode adds an instruction to
call a tool to the prompt, and docs/core-design.md stated that
tool_choice=required adds a prompt instruction and requires a completed call to
a declared tool. After this change, docs/api.md specifies that Jinja-template
and TMLv0 prompt encoders add a system instruction to call a tool to the prompt,
while the native DeepSeek V4 and V4.1 prompt encoders add none—rendering
required mode identically to "auto" in thinking mode so reasoning starts in
<think> and opening the DSML tool-call block at the end of the prompt in
non-thinking mode—and that completion validates at least one completed call to a
declared tool in all modes. docs/core-design.md now matches that split and links
to the conversation and tool semantics section of docs/api.md. No runtime code,
wire schemas, or compatibility contracts changed.

Expected result: callers and contributors reading either docs/api.md or
docs/core-design.md receive a consistent, accurate specification of prompt
rendering and completion enforcement for tool_choice: "required" across
Jinja-template, TMLv0, and native DeepSeek V4/V4.1 prompt encoders.

Verified every documented behavior directly against the checked-out source and
tests: PromptEncoder::renders_tool_choice (helios/src/frontend/mod.rs),
template_inputs (helios/src/server/request.rs), template_messages
(helios/src/server/inference.rs), conversation
(helios/src/frontend/deepseek.rs), Encoder::finish
(helios/src/server/protocol/encode.rs), and the integration tests
required_tools_in_chat_mode_start_inside_the_dsml_envelope and
required_and_named_tools_keep_the_thinking_prompt
(helios/tests/deepseek_requests.rs). Material limitation: because this commit
edits only documentation files (docs/api.md and docs/core-design.md), no
compilation, unit test execution, or GPU run was performed on this branch.

Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
@jcartu
jcartu force-pushed the docs/deepseek-required-tool-choice branch from 6a2cacc to 9ca1f72 Compare December 2, 2026 21:44
@jcartu jcartu changed the title docs(api): document DeepSeek V4/V4.1 behavior for tool_choice required docs: document DeepSeek V4/V4.1 behavior for tool_choice required Dec 2, 2026
@jcartu

jcartu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@flare-autobot Addressed both review items in 9ca1f72 (rebased onto main):

  • Should Fix Congratulations! #1 (docs/core-design.md:1727-1728): Updated the tool_choice=required summary so it requires a completed call to a declared tool while noting that Jinja-template and TMLv0 prompt encoders add a system prompt instruction and native DeepSeek V4 and V4.1 encoders do not, linking to api.md#conversation-and-tool-semantics.
  • Subtract / Simplify Congratulations! #1 (docs/api.md:666-674): Removed the internal "shared lowering" shorthand and undefined `chat` label, keeping the required-mode wording direct across Jinja-template, TMLv0, and native DeepSeek V4/V4.1 encoders.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

PR #686 cleanly resolves both items from the prior review at head 9ca1f72: docs/core-design.md is now aligned with docs/api.md, and the internal "shared lowering" / `chat` labels were removed. Every documented claim matches the verified runtime implementation and existing tests across Jinja-template, TMLv0, and native DeepSeek V4/V4.1 prompt encoders, with zero runtime or compatibility blast radius.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 0
Walkthrough
  • docs/api.md:666-674: Replaces the unconditional claim that tool_choice: "required" always appends a prompt instruction with the actual encoder split:
    • Jinja-template and TMLv0 prompt encoders append a system instruction to call a tool (helios/src/frontend/mod.rs:142-156, helios/src/server/request.rs:467-476, helios/src/server/inference.rs:387-390).
    • Native DeepSeek V4 and V4.1 prompt encoders append no instruction—rendering required mode identically to "auto" in thinking mode so reasoning begins in <think> (helios/src/frontend/deepseek.rs:272-280, helios/tests/deepseek_requests.rs:690-711), and opening the DSML tool-call block at the end of the prompt in non-thinking mode (helios/tests/deepseek_requests.rs:348-415).
    • Completion validation still enforces at least one completed call to a declared tool across all modes, including DeepSeek thinking mode (helios/src/server/protocol/encode.rs:582-584, :685-689).
  • docs/core-design.md:1727-1730: Replaces the stale unconditional tool_choice=required sentence with the matching encoder split and links to api.md#conversation-and-tool-semantics (verified against ## Conversation and tool semantics at docs/api.md:485).
Merge Risk: Low · up to 9ca1f72
  • Documentation-only diff across two Markdown files (docs/api.md +8/−3, docs/core-design.md +5/−2); no runtime, scheduler, grammar, wire-schema, cache, or build files are modified.
  • Zero concurrency, contention, memory/CPU/I/O, failure-propagation, or cross-platform regression surface.
  • Minor textual rebase overlap exists with the author's open PR Document strict tool selection and numeric range precision #461 (docs/api.md, required/named tool-choice paragraph); whichever merges second will need a trivial rebase with no semantic conflict.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Prose-only Markdown edits with one relative intra-doc anchor (api.md#conversation-and-tool-semantics); no code, scripts, external links, or prompt-injection vectors.
  • ✅ Charter & value fit: Directly addresses maintainer triage on tool_choice: "required" is dropped on DeepSeek V4/V4.1 in the default thinking mode #445 (yatesdr: "this is deliberate, and the gap is in the docs… The docs should say so") under the charter's "bad docs" merge criterion without adding per-model runtime branches.
  • ⚠️ Related / duplicate / conflict check: Not a duplicate; overlaps textually with the author's open PR Document strict tool selection and numeric range precision #461 on the same docs/api.md required-mode paragraph ("Sampling is unchanged" vs. "adds no decoding constraint"), requiring a small rebase when the second PR merges.
  • ✅ Tests & verification evidence: All statements were verified directly against the runtime implementation and existing unit/integration tests (helios/tests/deepseek_requests.rs:348-415, :690-711); omitting a build/GPU run is declared and appropriate for a docs-only diff.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation model:deepseek-v4 Affected recipe or documented reproducer: deepseek-v4. Impact may be broader. model:deepseek-v4.1 Affected recipe or documented reproducer: deepseek-v4.1. Impact may be broader. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tool_choice: "required" is dropped on DeepSeek V4/V4.1 in the default thinking mode

3 participants