Correctness and contracts report · NVIDIA/hyperflare-inference #686

Raw Markdown for agents: https://autobot.eidonix.com/p/a86ed4b0-d2f3-4706-a1af-c3a363344c85.md

Correctness, Contracts & System-Level Consequences review of PR #686 (head 9ca1f72)

Key findings

Verdict: sound. No blockers, no majors, no should-fix. Two Minor documentation nits. The diff is prose-only in two files (docs/api.md +8/−3, docs/core-design.md +5/−2, confirmed by pr_diff at 9ca1f72). There is no runtime, wire-schema, grammar, scheduler, cache, metric or admission surface in it, so lens areas 1 (correctness/safety/platform parity) and 2 (system-level consequences under load, failure propagation, memory, contention) are genuinely unaffected — stated plainly rather than filled with invented findings. What matters for this lens is whether the new normative text is true of the implementation and whether it creates a new contract claim the code does not honour. I traced every sentence to code and tests; one sentence is looser than the code, and one pointer is duplicated.


Findings

Minor 1 — docs/api.md:672-674: "Sampling is unchanged" is over-broad; the new prose omits the strict-tool grammar path

Severity: Minor. Citation: docs/api.md:672-674 at 9ca1f72bd0b40ead0fe13f20364fb876c6607295, against helios/src/server/request.rs:277-282.

Verbatim, docs/api.md:672-677 (the new text):

tool-call envelope. In all modes, including DeepSeek thinking mode, completion
validates that generation produced at least one completed call to a declared
tool. Sampling is unchanged; no calls are fabricated
and no retries are attempted. Missing calls, including output truncated before a
complete call, produce HTTP 500 for buffered requests or a terminal error event
for streams.

Verbatim, helios/src/server/request.rs:277-282:

            allow_undeclared: request.tool_choice == ToolChoice::Auto,
            require_call: matches!(
                request.tool_choice,
                ToolChoice::Required | ToolChoice::Named(_)
            ),
            single_call: !request.parallel_tool_calls,

Impact. The new paragraph frames required mode as an output-side check ("completion validates…") plus "Sampling is unchanged". For DeepSeek V4/V4.1 with an active strict function tool, that is not the whole mechanism: ToolGrammarPlan sets require_call: true for Required, so the required-call requirement is also compiled into the decoding grammar for the whole generation, and docs/api.md:760-768 (unchanged, later in the same section) states that an active strict tool forces device-masked decoding at MTP width one with one step in flight. A reader who takes "Sampling is unchanged" literally for a strict-tool DeepSeek request will mis-model the request: with a strict tool, both the sampling path (speculative width / replay loop) and the grammar differ. This is the one place where the new text is looser than the code; it is a documentation-precision issue, not a behavioural bug, and it does not contradict any other sentence in the diff (the later paragraph still covers strict tools).

Concrete fix. Add a half-clause rather than new structure, e.g. after "Sampling is unchanged": "…unless an active strict tool also requires the call in the request grammar (see below)". Cheaper still: change "Sampling is unchanged" to "Without an active strict tool, sampling is unchanged". No cross-reference restructuring needed.


Minor 2 — docs/core-design.md:1729-1730: duplicate pointer to the same api.md section, two sentences apart

Severity: Minor. Citation: docs/core-design.md:1729-1730 and :1735 at 9ca1f72.

Verbatim, docs/core-design.md:1727-1736 (new text is 1727-1730):

`tool_choice=required` requires a completed call to a declared tool;
Jinja-template and TMLv0 prompt encoders also add a system prompt instruction,
while native DeepSeek V4 and V4.1 encoders do not (see the
[API contracts](api.md#conversation-and-tool-semantics)). Without a grammar it
uses ordinary sampling. Named tool
selection filters the definitions to that tool; it does not by itself enable a
grammar. The encoder requires a completed call to the selected tool and rejects
other tool names. It omits ordinary answer text but preserves reasoning and arguments.
`tool_choice=none` removes tools from the template. See the [API contracts](api.md)
for the accepted strict schema subset, parser formats, protocol mappings and streamed errors.

Impact. Two links to api.md in adjacent sentences, the second to the same document (broader anchor). Cosmetic only; the habit of precise anchors is good. The anchor itself is valid — docs/api.md:485 is ## Conversation and tool semantics (read at 9ca1f72), so the deep link resolves by inspection.

Concrete fix. Keep the precise deep link at :1729-1730 and demote the pre-existing one at :1735 to plain text ("See the API contracts for…"), or vice versa.


What I verified as accurate (no finding)

Every behavioural claim in the two hunks maps to code and existing tests at the PR head:

  1. "Jinja-template and TMLv0 prompt encoders add a system instruction." helios/src/frontend/mod.rs:151-156 — renders_tool_choice is matches!(self, Self::DeepseekV4 | Self::DeepseekV41), and the enum at :140-149 has exactly four variants (Jinja, DeepseekV4, DeepseekV41, TmlV0), so the doc's two-bucket split is exhaustive with no encoder left unclassified. helios/src/server/request.rs:467 let shared_lowering = !frontend.prompt_encoder().renders_tool_choice(); and :472-476 pass the request's tool_choice into template_messages only when shared_lowering; helios/src/server/inference.rs:387-390 appends "You must call at least one of the provided tools in your next response. Choose the appropriate tool and arguments."
  2. "Required mode needs at least one declared tool" (carried over, unchanged in meaning) — helios/src/server/inference.rs:387-390 path plus helios/src/frontend/deepseek.rs:272-273; test helios/tests/deepseek_requests.rs:709 assert!(fixture.prepare(json!({"tool_choice":"required","tools":[]})).is_err());.
  3. "In thinking mode they render required mode identically to auto so reasoning starts in <think>." helios/src/frontend/deepseek.rs:275-280 (Required → Auto when thinking_mode). Test helios/tests/deepseek_requests.rs:689-711 asserts required.rendered_prompt == automatic.rendered_prompt, equal prompt.tokens, OutputStart::Reasoning, and rendered_prompt.ends_with("<|Assistant|><think>"), across thinking defaults/enable_thinking:true/thinking_mode:"thinking".
  4. "In non-thinking mode their template opens the DSML tool-call block at the end of the prompt." Test helios/tests/deepseek_requests.rs:347-415 asserts output.content.start == OutputStart::ToolBody and rendered_prompt.trim_end().ends_with("<|DSML|tool_calls>") (V4) / "<|DSML| calls>" (V4.1), with enable_thinking:false and tool_choice:"required".
  5. "In all modes … completion validates that generation produced at least one completed call to a declared tool." helios/src/server/protocol/encode.rs:582-584 rejects an undeclared tool name whenever tool_choice != Auto, and :685-689 errors with "required tool choice was not satisfied…" when Required | Named(_) produced no completed tools. This is the asymmetry the PR documents: the prompt is lowered to Auto for native DeepSeek, but the output-side validation still sees the semantic tool_choice. (That the encoder is constructed with the semantic value was confirmed in research at helios/src/server/http.rs:366 (not opened); this run I re-opened and re-verified only encode.rs:570-600 and :670-700.)

Area-by-area disposition


Observations that are not findings


Open questions / could not verify

  1. Whether api.md#conversation-and-tool-semantics renders as intended on GitHub — heading ## Conversation and tool semantics exists at docs/api.md:485, verified by reading, not by rendering.
  2. #461's live hunks — unverifiable locally; the only outstanding merge-order question.
  3. No human maintainer has reviewed any version of #686; the only review is the bot's, and yatesdr (who requested the doc fix in #445) has not commented.
  4. Tool caveat: reading files at ref pr/686 earlier returned the pre-push (6a2cacc) content of both docs while pr_files/pr_diff showed the new state, so all line numbers above were pinned to commit 9ca1f72bd0b40ead0fe13f20364fb876c6607295 and re-read this run.