Skip to content

fix(helios): preserve Chat reasoning aliases, normalize Chat effort levels, and allow literal closing tool tags in O(N) - #677

Merged
lukealonso merged 1 commit into
NVIDIA:mainfrom
brandonmmusic-max:fix/helios-glm53-tool-and-reasoning
Dec 4, 2026
Merged

lukealonso merged 1 commit into
NVIDIA:mainfrom
brandonmmusic-max:fix/helios-glm53-tool-and-reasoning

Conversation

@brandonmmusic-max

@brandonmmusic-max brandonmmusic-max commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Why this change is needed

OpenAI-compatible Chat Completions clients and tagged tool-call parsers encounter two failure modes in Helios request decoding and output parsing:

  1. Multi-turn assistant reasoning loss and Chat Completions effort-level mismatch (helios/src/server/protocol/decode.rs, helios/src/frontend/mod.rs):
    • chat_messages read only reasoning_content and ignored thinking and reasoning aliases on assistant messages, dropping prior reasoning across multi-turn tool loops when clients store reasoning under those field names.
    • Top-level named reasoning_effort strings (none, minimal, medium, high, max) were copied verbatim into options.template["reasoning_effort"] instead of being normalized against the prepared encoder's effort vocabulary. Strict templates rejected out-of-vocabulary levels with HTTP 400 (such as Qwen3.8 on high/max and native DeepSeek encoders on none/minimal/medium), fallback templates (such as GLM-5.3) fell through to max on medium, and nested reasoning.effort objects on Chat Completions were ignored.
  2. HTTP 500 on literal closing tool tags inside non-JSON tagged argument values (helios/src/output/):
    • Previously, ToolDialect::parse_candidate returned Result<Option<Vec<(String, String)>>> where None signaled only an open JSON string, causing TaggedTools::push to enter JSON quote-skipping mode until the next unescaped double quote. When a non-JSON string argument in GLM argument-tag syntax (<arg_key>...<arg_value>...</arg_value>), ChatML function-tag syntax (<parameter=...>...</parameter>), or Gemma call syntax (<|"|>...<|"|>) contained a literal outer closing tool tag (</tool_call> or <tool_call|>), TaggedTools::push split the call body at the inner tag and the dialect parser aborted the request with an unterminated-value error.

What changed

Before this change, chat_messages read only reasoning_content, Chat Completions forwarded named reasoning_effort strings directly into options.template, Frontend::resolve_effort accepted any Jinja level that did not raise an error (treating fallback-branch medium as supported), TaggedTools::push supported only JSON quote-skipping, and docs/api.md documented named effort resolution only for Responses and Messages.

After this change:

  • helios/src/server/protocol/decode.rs:
    • chat_messages reads the first non-null of reasoning_content, thinking, or reasoning on Role::Assistant messages (keeping non-assistant roles isolated from generic thinking and reasoning keys) and rejects non-string values naming the offending field.
    • options uses present() to accept nested reasoning.effort on Chat Completions when top-level reasoning_effort is absent or null, and replaces the mutable tracking flag with an immutable withheld_chat_effort binding covering top-level none (enable_thinking=false), minimal, low, medium, high, and max, while preserving raw passthrough for xhigh (so DeepSeek-V4.1 keeps score 75 vs max's 100), numeric scores, padded/unknown top-level strings, explicit enable_thinking, and chat_template_kwargs overrides.
  • helios/src/server/inference.rs, helios/src/server/request.rs, and helios/src/frontend/mod.rs:
    • Added Effort::Medium (&["medium", "high"]) for top-level Chat "medium" so PromptEncoder::TmlV0 (Inkling 2) preserves its native 0.7 level on Chat Completions (tests/frontend/inkling2_tml.json:318-341), while Responses reasoning.effort: "medium" stays Effort::High (0.9).
    • Updated Jinja probing in Frontend::resolve_effort to compare rendered output against an unknown-effort sentinel so fallback-branch templates (such as GLM-5.3's low/high/else -> max) exclude fallback-only "medium" and resolve Effort::Medium to "high", while strict templates (such as Qwen3.8's low/medium/xhigh) resolve "high" to "medium" and "max" to "xhigh".
  • helios/src/output/{tagged.rs,tagged/kani_proofs.rs,argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs}:
    • Rebased cleanly over feat(helios,ignition): parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser, and propagate peer source roots #670 (TaggedJson and parameterized delimiters).
    • Replaced Option with #[derive(Debug, PartialEq, Eq)] pub enum Candidate { Complete(...), InJsonString, IncompleteValue } and added ToolDialect::scan_value_end plus TaggedTools::in_value (updating eos_decision and kani_proofs.rs). After Candidate::IncompleteValue, TaggedTools::push scans linearly in O(N) for the dialect's value-ending boundary (</arg_value>, </parameter> / <parameter= / </function>, or <|"|>) instead of reparsing from byte 0 on every inner closing tag.
    • Removed redundant incomplete-value mode flags and dead match arms across argument_tags.rs, chatml.rs, and gemma_call.rs while keeping direct parse and parse_eos rejection of unterminated values unchanged.
  • docs/api.md:
    • Documented assistant reasoning aliases, Chat Completions named effort normalization and nested reasoning.effort (including TMLv0 Chat 0.7 vs Responses 0.9 and Qwen/GLM/DeepSeek vocabularies), and O(N) literal closing-tag handling inside non-JSON tagged argument values.

Claimed benefit and compatibility impact

  • Preserves multi-turn assistant reasoning across thinking and reasoning aliases without affecting non-assistant roles, normalizes Chat Completions named efforts and nested reasoning.effort across Jinja, DeepSeek, and TMLv0 encoders without breaking TMLv0's 0.7 Chat medium golden contract or DeepSeek-V4.1's xhigh (75) and numeric scores, and parses literal outer closing tool tags inside non-JSON tagged arguments in O(N) time while preserving strict tool validation, the 1 MiB buffer bound, and EOS truncation rejection.
  • Compatibility notes: (a) non-string thinking or reasoning fields on Chat Completions assistant messages now return HTTP 400; (b) malformed adjacent calls where an unclosed argument value precedes a second call's closing tag remain ambiguous at the text-delimiter level; (c) no model core format or wire schema changes are introduced.

Supporting evidence and limitations

  • CPU validation with prepared templates (FLARE_TEST_TEMPLATE_DIR generated by tests/frontend/prepare_templates.py):
    • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server: 1,841 unit tests passed (47 ignored) and 62 integration tests passed (37 ignored), 0 failed, including new unit tests covering assistant-only reasoning aliases, effort normalization across GLM-style fallback Jinja, Qwen3.8-style strict Jinja, TMLv0, and DeepSeek-V4.1, two-part UTF-8 splits and single-character streaming across all four dialects, and 40,000-tag (~480 KiB) linear-scan stress tests for ArgumentTags, ChatMlOutput, and GemmaCall.
    • FLARE_INKLING2_TEST_SNAPSHOT=... cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server -- --ignored tml_tests: 6 passed, 0 failed, including prompts_match_tml_renderers_token_for_token.
    • cargo test --locked --release --manifest-path flare/Cargo.toml: 254 passed (4 ignored), 0 failed.
    • cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 245 passed (3 ignored), 0 failed.
    • cargo check --locked --release --manifest-path helios/Cargo.toml passed across default, frontend, images, server, and runtime-core,server.
  • Limitations: cargo-kani and cargo-mutants are not installed on the validation host, so helios/src/output/tagged/kani_proofs.rs (updated for TaggedTools::in_value and eos_decision) was reviewed directly rather than executed with cargo kani. GPU-gated ignored tests were not executed on CPU.

Discord: Brandonmusic

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 677.
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. bug Something isn't working priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. 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

Both core fixes are sound—the three-state Candidate split rejects EOS correctly without weakening strict-tool validation, and the Chat alias lookup preserves multi-turn reasoning history—but the PR cannot merge as-is: Chat "reasoning_effort": "medium" is withheld and remapped to Effort::High, silently shifting TMLv0 (Inkling 2) from 0.7 to 0.9 and breaking the in-repo golden test prompts_match_tml_renderers_token_for_token. It also adds an O(K·N) prefix reparse on the presentation hot path, leaves "high" unnormalized for Qwen3.8, and omits the required docs/api.md update.

  • Blockers: 1 · Should fix: 3 · Subtract/Simplify: 2 · Nits: 3
Walkthrough
  • helios/src/server/protocol/decode.rs
    • chat_messages (:184-193) reads the first non-null of reasoning_content, thinking, reasoning and rejects non-string values naming the offending key.
    • options (:590-638, :677-690) accepts nested reasoning.effort on Chat Completions when top-level reasoning_effort is absent or null; normalizes top-level "none", "minimal", "medium" via enable_thinking: false / options.effort while withholding those raw strings from options.template; preserves numeric/unknown passthrough and chat_template_kwargs precedence; rejects unsupported nested reasoning.effort values.
    • Added isolated unit tests (:2429-2656) exercising real decode + prepare_inference on Jinja and DeepseekV41 encoders.
  • helios/src/output/tagged.rs
    • Added pub enum Candidate { Complete(Vec<(String, String)>), InJsonString, IncompleteValue } (:31-39); ToolDialect::parse_candidate (:50-52) now returns Result<Candidate>.
    • TaggedTools::push (:336-347) sets self.in_json_string = true only on Candidate::InJsonString and keeps scanning past an inner closing tag on Candidate::IncompleteValue, preserving the 1 MiB buffer bound (:303-305) and eos_decision (:257-271).
  • helios/src/output/{argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs}
    • ArgumentTags, FunctionTags (ChatMlOutput/CompactChatMlOutput), and GemmaCall return Candidate::IncompleteValue for open argument/parameter/<|"|>-quoted values during candidate evaluation while retaining parse/parse_eos errors for unterminated values; MiniMaxXml (minimax_xml.rs:200-202) adapted to Candidate::Complete (namespace-prefixed closer).
    • Added exhaustive two-part UTF-8 split, single-character streaming, strict-tool, and EOS/non-EOS termination unit tests across all four dialects.
Merge Risk: Medium · up to f439f74
  • Silent prompt/prefix-cache shift and golden-test breakage on TMLv0 (Inkling 2): Chat "reasoning_effort": "medium" changes from 0.7 to 0.9, breaking helios/src/server/request/tml_tests.rs:104-114 (tests/frontend/inkling2_tml.json:318-341) and shifting prompt token IDs and prefix-cache keys on upgrade.
  • Output presentation hot-path CPU regression: TaggedTools::push (helios/src/output/tagged.rs:306-348) restarts D::parse_candidate from byte 0 on every literal inner closer inside an open value (O(K·N) up to the 1 MiB bound), risking stalls on the Tokio response task for tag-heavy or repetitive tool arguments. No new locks, threads, shared caches, or cross-request failure blast radius.
  • Multi-PR collision surface: Open PR feat(helios,ignition): parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser, and propagate peer source roots #670 (lukealonso) modifies the same ToolDialect/TaggedTools::push/parse_candidate region of helios/src/output/tagged.rs and argument_tags.rs and adds TaggedJson implementing ToolDialect::parse_candidate; landing order and rebase must be coordinated.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: No unsafe code, secret/exfiltration vectors, or prompt-injection paths; malformed/unterminated calls still fail closed at EOS and the 1 MiB parser buffer bound is preserved (O(K·N) CPU rescan tracked under Should Fix).
  • ⚠️ Charter & value fit: Aligned with documented OpenAI API support and keeping Helios model-agnostic, but bundles two independent fixes in one PR, omits required docs/api.md updates (AGENTS.md:230), and does not disclose the TMLv0 0.7 → 0.9 shift in the PR description (docs/design-review.md Principle 16).
  • ⚠️ Related / duplicate / conflict check: Not a duplicate, but directly conflicts with open PR feat(helios,ignition): parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser, and propagate peer source roots #670 (helios/src/output/tagged.rs and argument_tags.rs, plus tagged_json.rs (not opened)'s ToolDialect::parse_candidate signature) and interacts with open docs PR [Fix] Document: GLM 5.3 Flash always uses thinking #172 (docs/api.md GLM effort wording).
  • ⚠️ Tests & verification evidence: All new Rust unit tests are isolated, mutate no process-global state, and exercise real production entry points; helios/src/output/tagged/kani_proofs.rs targets are structurally unchanged. However, the #[ignore]d Inkling 2 golden test prompts_match_tml_renderers_token_for_token (helios/src/server/request/tml_tests.rs:104-114) is broken by this change, and the external SM120/BFCL/agentic_suite.py (not opened) claims have no in-tree harness, core ID, command, or log (agentic_suite/BFCL do not exist in-repo).

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.

…evels, and allow literal closing tool tags in O(N)

OpenAI-compatible Chat Completions requests and tagged tool-call parsers hit
two failure modes in Helios:
1. Chat Completions message decoding read only `reasoning_content` and ignored
   `thinking` and `reasoning` aliases on assistant messages, dropping prior
   reasoning across multi-turn tool loops. In addition, named top-level
   `reasoning_effort` strings (`none`, `minimal`, `medium`, `high`, `max`) were
   copied verbatim into `options.template["reasoning_effort"]` instead of being
   resolved against the prepared encoder's effort vocabulary, causing strict
   templates (such as Qwen3.8 on `high`/`max`) and native DeepSeek encoders (on
   `none`/`minimal`/`medium`) to return HTTP 400 and fallback templates (such
   as GLM-5.3 on `medium`) to fall through to `max`. Nested `reasoning.effort`
   on Chat Completions was ignored.
2. Tagged tool-call dialects (`ArgumentTags`, `FunctionTags`, `GemmaCall`)
   returned `Result<Option<Vec<(String, String)>>>` from
   `ToolDialect::parse_candidate`, where `None` signaled only an open JSON
   string. When a non-JSON string argument (`<arg_value>`, `<parameter=...>`,
   or `<|"|>`) contained a literal outer closing tool tag (`</tool_call>` or
   `<tool_call|>`), `TaggedTools::push` split the call body at the inner tag
   and aborted the request with an unterminated-value error.

Before this change, `chat_messages` read only `reasoning_content`, Chat
Completions passed named `reasoning_effort` strings directly into
`options.template`, `Frontend::resolve_effort` accepted any Jinja level that
did not raise an error (treating fallback-branch `medium` as supported),
`TaggedTools::push` handled only JSON string skipping, and `docs/api.md`
documented named effort normalization only for Responses and Messages. After
this change:
- `helios/src/server/protocol/decode.rs`: `chat_messages` reads the first
  non-null of `reasoning_content`, `thinking`, or `reasoning` on `Role::Assistant`
  messages (keeping non-assistant roles isolated from generic `thinking` and
  `reasoning` keys) and rejects non-string values naming the offending field.
  `options` accepts nested `reasoning.effort` on Chat Completions when
  top-level `reasoning_effort` is absent or null, and normalizes top-level
  named `none`, `minimal`, `low`, `medium`, `high`, and `max` through
  `options.effort` / `enable_thinking` while keeping `xhigh`, numeric scores,
  padded/unknown top-level strings, explicit `enable_thinking`, and
  `chat_template_kwargs` overrides intact.
- `helios/src/server/inference.rs`, `helios/src/server/request.rs`, and
  `helios/src/frontend/mod.rs`: added `Effort::Medium` (`&["medium", "high"]`)
  for top-level Chat `"medium"` so `PromptEncoder::TmlV0` (`Inkling 2`)
  preserves its native `0.7` level on Chat Completions while Responses
  `reasoning.effort: "medium"` remains `Effort::High` (`0.9`). In
  `Frontend::resolve_effort`, Jinja probing compares rendered output against an
  unknown-effort sentinel so fallback-branch templates (such as GLM-5.3's
  `low`/`high`/`else -> max`) exclude fallback-only `"medium"` and resolve
  `Effort::Medium` to `"high"`, while strict templates (such as Qwen3.8's
  `low`/`medium`/`xhigh`) resolve `"high"` to `"medium"` and `"max"` to
  `"xhigh"`.
- `helios/src/output/{tagged.rs,tagged/kani_proofs.rs,argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs}`:
  replaced `Option` with `#[derive(Debug, PartialEq, Eq)] pub enum Candidate
  { Complete(...), InJsonString, IncompleteValue }`, added
  `ToolDialect::scan_value_end` and `TaggedTools::in_value` (updated
  `eos_decision` and `kani_proofs.rs` accordingly) so an open non-JSON argument
  value scans linearly in O(N) for its dialect terminator (`</arg_value>`,
  `</parameter>` / `<parameter=` / `</function>`, or `<|"|>`) without reparsing
  the prefix on repeated inner closing tags, and kept direct `parse` and
  `parse_eos` rejection of unterminated values unchanged without redundant mode
  flags. Rebased cleanly over NVIDIA#670 (`TaggedJson` and parameterized delimiters).
- `docs/api.md`: updated the tagged tool-call and reasoning/effort sections to
  document assistant reasoning aliases, Chat named effort normalization and
  nested `reasoning.effort`, encoder-specific effort resolution (including
  TMLv0 Chat `0.7` vs Responses `0.9`), and O(N) literal closing-tag handling.

Claimed result: preserves multi-turn assistant reasoning across `thinking` and
`reasoning` aliases, resolves Chat Completions named efforts and nested
`reasoning.effort` consistently across Jinja, DeepSeek, and TMLv0 encoders
without breaking TMLv0's `0.7` Chat `medium` contract or DeepSeek-V4.1's
`xhigh` (`75`) and numeric scores, and parses literal outer closing tool tags
inside non-JSON tagged arguments in O(N) time while preserving strict tool
validation, the 1 MiB buffer bound, and EOS truncation rejection. No model core
format or wire schema changes are introduced.

Validation and limitations (CPU, `FLARE_TEST_TEMPLATE_DIR` prepared via
`tests/frontend/prepare_templates.py`):
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server`:
  1,841 unit tests passed (47 ignored) and 62 integration tests passed (37
  ignored), 0 failed — including new tests for assistant-only reasoning aliases,
  effort normalization across GLM-style fallback Jinja, Qwen3.8-style strict
  Jinja, TMLv0, and DeepSeek-V4.1, two-part UTF-8 splits and single-character
  streaming across all four dialects, and 40,000-tag (~480 KiB) linear-scan
  stress tests for `ArgumentTags`, `ChatMlOutput`, and `GemmaCall`.
- `FLARE_INKLING2_TEST_SNAPSHOT=... cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server -- --ignored tml_tests`:
  6 passed, 0 failed (including `prompts_match_tml_renderers_token_for_token`).
- `cargo test --locked --release --manifest-path flare/Cargo.toml`: 254 passed
  (4 ignored), 0 failed.
- `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`: 245
  passed (3 ignored), 0 failed.
- `cargo check --locked --release --manifest-path helios/Cargo.toml` passed
  across default, `frontend`, `images`, `server`, and `runtime-core,server`.
- Limitations: `cargo-kani` and `cargo-mutants` are not installed on the
  validation host, so `helios/src/output/tagged/kani_proofs.rs` (updated for
  `TaggedTools::in_value` and `eos_decision`) was reviewed directly rather than
  executed with `cargo kani`. GPU-gated ignored tests were not run on CPU.

Design-Signed-Off-By: Brandon M. Music; design-review=2e5b
Signed-off-by: Brandon M. Music <266531604+brandonmmusic-max@users.noreply.github.com>
@brandonmmusic-max
brandonmmusic-max force-pushed the fix/helios-glm53-tool-and-reasoning branch from f439f74 to c897437 Compare December 2, 2026 21:29
@brandonmmusic-max brandonmmusic-max changed the title fix(helios): preserve Chat Completions reasoning aliases, normalize effort levels, and allow literal closing tool tags in argument values fix(helios): preserve Chat reasoning aliases, normalize Chat effort levels, and allow literal closing tool tags in O(N) Dec 2, 2026
@brandonmmusic-max

Copy link
Copy Markdown
Contributor Author

Rebased onto main (cc0a49d2, over merged #670) and addressed all Autobot blocker, should-fix, simplify, and nit findings:

  • Blocker (TMLv0 Chat medium 0.7 vs Responses 0.9): Added Effort::Medium (&["medium", "high"]) for top-level Chat "medium" while keeping Responses "medium" on Effort::High, and updated Jinja effort probing in Frontend::resolve_effort to detect fallback-only "medium" via an unknown-effort sentinel. Verified directly against the Inkling 2 golden suite: tml_tests passed 6/6 including prompts_match_tml_renderers_token_for_token.
  • Should Fix Congratulations! #1 (O(K·N) rescan on Candidate::IncompleteValue): Added ToolDialect::scan_value_end and TaggedTools::in_value (with eos_decision and helios/src/output/tagged/kani_proofs.rs updated) so open non-JSON argument values scan linearly in O(N) for their dialect terminator (</arg_value>, </parameter> / <parameter= / </function>, or <|"|>). Verified with 40,000-tag (~480 KiB) stress tests across ArgumentTags, ChatMlOutput, and GemmaCall.
  • Should Fix flare run fails at "Prepare execution": cuGraphAddKernelNode_v2 CUDA_ERROR_INVALID_VALUE (qwen3.8-flash TP2, RTX PRO 5000 Blackwell 48 GB) #2 (Qwen3.8 Chat "high" and "max"): Included "high" and "max" in Chat effort normalization (leaving "xhigh" raw so DeepSeek-V4.1 keeps 75 vs 100) and added Qwen3.8-vocabulary (low/medium/xhigh) unit tests.
  • Should Fix Message prefix checkpoint skipped at a conditioned window boundary #3 (docs/api.md): Updated the tagged tool-call and reasoning/effort sections in docs/api.md.
  • Simplifications & Nits: Removed redundant allow_incomplete_value flags and dead match arms across argument_tags.rs, chatml.rs, and gemma_call.rs; reused present() and replaced mutable normalized_chat_effort with an immutable withheld_chat_effort binding in decode.rs; restricted thinking/reasoning alias lookup to Role::Assistant; added #[derive(Debug, PartialEq, Eq)] to Candidate; cleaned PR evidence to strictly in-repo reproducible checks.

Validated on CPU: helios 1,841 unit + 62 integration passed, Inkling 2 tml_tests 6/6 passed, flare 254 passed, flare-cli 245 passed, and all 5 helios feature checks passed. @flare-autobot please re-review.

@flare-autobot flare-autobot added model:inkling-small Affected recipe or documented reproducer: inkling-small. Impact may be broader. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

All Round 1 blockers, should-fix items, and the #670 rebase conflict are resolved cleanly at head c897437: Chat top-level "medium" preserves TMLv0 (Inkling 2) native 0.7 via Effort::Medium while normalizing across GLM fallback and Qwen3.8 strict templates, and non-JSON tagged argument scanning now runs in linear O(N) time via ToolDialect::scan_value_end and TaggedTools::in_value without weakening EOS rejection or the 1 MiB buffer cap. No new correctness, safety, or hot-path regressions were introduced; the remaining items are optional follow-up cleanups and minor nits.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 4 · Nits: 3
Walkthrough
  • helios/src/server/protocol/decode.rs:
    • chat_messages (:184-199) reads the first non-null of reasoning_content, thinking, or reasoning on Role::Assistant messages (keeping non-assistant roles on reasoning_content only) and returns HTTP 400 naming the offending key for non-string values.
    • options (:596-638, :677-696) accepts nested reasoning.effort on Chat Completions when top-level reasoning_effort is absent or null, maps top-level Chat "medium" to Effort::Medium (leaving nested/Responses "medium" on Effort::High), and withholds normalized top-level Chat names (none, minimal, low, medium, high, max) from options.template while preserving passthrough for "xhigh", numeric scores, unknown top-level strings, explicit enable_thinking, and chat_template_kwargs.
    • Adds isolated unit tests (:2436-2759) exercising real decode + prepare_inference across Jinja (GLM fallback & Qwen3.8 strict), TmlV0 (Inkling 2), and DeepseekV41.
  • helios/src/server/inference.rs, helios/src/server/request.rs, helios/src/frontend/mod.rs:
    • Adds Effort::Medium (inference.rs:121-122) with candidate ladder &["medium", "high"] (request.rs:521).
    • Updates Frontend::resolve_effort (frontend/mod.rs:853-880) to probe Jinja templates with sentinel "__flare_unknown_effort__" and exclude fallback-only "medium" when the template renders distinct levels, so GLM-style low/high else max templates resolve Effort::Medium to "high".
  • helios/src/output/{tagged.rs,tagged/kani_proofs.rs,argument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs}:
    • Replaces Option with #[derive(Debug, PartialEq, Eq)] pub enum Candidate { Complete(...), InJsonString, IncompleteValue } (tagged.rs:31-37), adds ToolDialect::scan_value_end (tagged.rs:61-63) and TaggedTools::in_value (tagged.rs:241, 292, 350-361, 400, 406, 419), and updates tagged/kani_proofs.rs:99-136 to cover in_value in eos_decision.
    • Implements linear value-end scanners for ArgumentTags (argument_tags.rs:117-123), FunctionTags (chatml.rs:30-47, 100-119), and GemmaCall (gemma_call.rs:176-181), adapts MiniMaxXml (minimax_xml.rs:200-202), removes redundant mode flags, and adds split-sweep, single-char streaming, strict-tool, EOS/non-EOS, and 40,000-tag stress tests.
  • docs/api.md:
    • Documents literal closing tool tags inside non-JSON argument values (:621-625) and assistant reasoning aliases, nested reasoning.effort, Chat named effort normalization, and encoder vocabularies including TMLv0 0.7 vs 0.9 (:975-995).
Merge Risk: Low · up to c897437
  • Output parser hot path (helios/src/output/): TaggedTools::push retains the 1 MiB buffer bound (helios/src/output/tagged.rs:329-331), preserves strict-tool and EOS rejection (in_value participates in EosDecision::Reject at tagged.rs:292), and scans open non-JSON values monotonically in O(N) with UTF-8 char-boundary safety across all three IncompleteValue dialects (ArgumentTags, FunctionTags, GemmaCall). No shared state or locks are added.
  • Request decoding & effort resolution (helios/src/server/protocol/decode.rs, helios/src/frontend/mod.rs): Template vocabulary probing runs once per Frontend inside OnceLock::get_or_init (frontend/mod.rs:799, 843), adding zero per-request template renders or contention. TMLv0 Chat "medium" (0.7), Responses "medium" (0.9), and DeepSeek-V4.1 "xhigh" (75) vs "max" (100) and numeric scores are preserved without shifting existing prompt contracts.
  • Cross-PR surface: Cleanly rebased over merged #670 (TaggedJson / JSON_BODY / with_tool_delimiters). Open docs PR #172 (already in Changes Requested with docs/api.md merge conflicts) will need to align its GLM effort wording when it rebases, which does not block #677.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: No unsafe code, exfiltration, or prompt-injection vectors; 1 MiB parser buffer bound (tagged.rs:329-331), strict schema validation, and fail-closed EOS rejection (tagged.rs:292) are preserved, and O(K·N) rescanning is eliminated.
  • ✅ Charter & value fit: Aligns with documented OpenAI Chat Completions support, model-agnostic Helios layers (Effort::Medium + dialect-generic Candidate/scan_value_end), and required docs/api.md updates; minor bundling of two fixes remains noted under Nits.
  • ✅ Related / duplicate / conflict check: Not a duplicate; cleanly rebased over merged #670 (TaggedJson, JSON_BODY, with_tool_delimiters); open docs PR #172 will rebase its GLM effort note onto this.
  • ⚠️ Tests & verification evidence: All new Rust tests are isolated, mutate no global state, and exercise real production entry points (with external unverified GPU/BFCL claims removed from the PR description); warning solely because cargo-kani / cargo-mutants were not run on the validation host (honestly disclosed; kani_proofs.rs:99-136 verified statically) and test counts rely on CI/author execution.

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.

@lukealonso
lukealonso merged commit 708be5b into NVIDIA:main Dec 4, 2026
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. bug Something isn't working model:inkling-small Affected recipe or documented reproducer: inkling-small. Impact may be broader. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. 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.

3 participants