PR #677: fix(helios): preserve Chat Completions reasoning aliases, normalize effort levels, and allow literal closing tool tags in argument values

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/203cfc55-02b8-426d-9aa5-a86a62d8d1d8

Opened by a workflow run, Dec 2, 2026 5:58 AM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: brandonmmusic-max (GitHub association CONTRIBUTOR; not on the charter's priority-contributor list; Discord "Brandonmusic"). One prior merged PR in the same file (helios/src/output/tagged.rs, #162). Motivation: OpenAI-compatible Chat Completions clients were losing earlier reasoning turns because Helios only read the reasoning_content field, and were getting HTTP 400 (or silently maximum effort) when they sent effort levels like "none", "minimal" or "medium", which never went through the same resolution Responses and Messages use. Separately, a tagged tool call whose argument value happened to contain the literal outer closing tag (e.g. a grep pattern </tool_call>) split the call and made the whole request fail with HTTP 500. Scale: +791 / −59 lines in 6 files Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #677 (helios): Chat reasoning aliases, effort normalization, literal closing tool tags

Charter alignment

Both halves sit inside the stated goal of supporting "the documented Chat Completions, Completions, Responses, and Messages APIs." The decode half implements "Don't silently ignore API fields… either implement it according to the spec or reject it" — today thinking/reasoning history and nested reasoning.effort are dropped, and none/minimal/medium are forwarded raw into options.template. The output half fixes a parser failure in the shared layer via a general Candidate enum, not per-model branches. No proto, core-format, config, or dependency change; no new model recipe, alias, or format is proposed, so the recipe-ownership rule doesn't apply.

Novelty and status

Not obsolete, not superseded. No merged commit covers either defect; #596/#573/#418/#67 are preserved, not reversed. #670 touches the same tagged.rs/parse_candidate region for contract-supplied delimiters — conflict risk, not coverage. Genuinely additive; the only real issue is merge order with #670.

Value vs cost

Beneficiaries are real: Chat clients echoing reasoning under thinking/reasoning, and GLM/ChatML/Gemma tool-call parsers. The new Rust tests are self-contained and sweep every two-part split and single-character streaming while asserting unterminated values still reject at EOS — solid evidence for the parser half. The SM120/BFCL/agentic_suite.py claims have no harness, core id, command or log in the tree, and the same weakness was flagged on the author's #457.

Costs are not trivial. The decode half is an undeclared behaviour change: Chat medium on TMLv0 moves 0.7→0.9 (frontend/tml.rs:19-27), shifting prompt tokens and therefore prefix-cache keys; high is left unnormalized, so Qwen3.8-style templates still reject it; unknown nested effort errors while unknown top-level does not; two unrelated fixes are bundled; and docs/api.md (:955-995, :539-547, :596-628) is untouched despite AGENTS.md:230, while open docs-only PR #172 still records pre-#677 GLM behaviour.

Required changes

  1. Update docs/api.md; reconcile with #172.
  2. Disclose the TMLv0 medium 0.7→0.9 shift (or exclude it) and justify leaving high unnormalized.
  3. Split decode and output into separate PRs.
  4. Settle merge order with #670 and rebase accordingly.
  5. Supply a reproducible core id/command/log for the reported HTTP 500.

Verdict

Worth it with changes — the parser fix is a genuine, well-tested bug fix and the decode half closes a documented-API gap, but it should not land as-is given the undocumented effort shift, incomplete high handling, missing docs, and the #670 conflict.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, priority:P2, bug, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +priority:P2, +bug, +area:api

Subtraction and simplicity

PR #677 is mostly lean; the findings are spare-part removal, not redesign.

  1. chatml.rs:91-96 + :103 + :168-174 — allow_incomplete_value makes the Candidate::IncompleteValue arm unreachable (both parse :25 and parse_eos :31 pass false) and duplicates "unterminated tool parameter value". Drop the 5th parameter; else { return Ok(Candidate::IncompleteValue) } keeps the identical message.
  2. gemma_call.rs:150-159 + :127 — same flag; parse :175-182 and parse_eos :186-193 already map IncompleteValue to the same string, so collapse the 10-line match to 4.
  3. argument_tags.rs:85-91 — eos-conditional Err is redundant with parse_eos :121-128; return Ok(Candidate::IncompleteValue) (only the EOS message changes). Together 1-3 give one rule for three dialects.
  4. decode.rs:590-592 re-implements present() (:38-40), and normalized_chat_effort is assigned in three match arms (:613/:617/:622) to be read once at :684; one withheld bool computed after the match removes both.
  5. Convention: docs/api.md untouched although AGENTS.md:230 requires it; api.md:960-965 scopes named levels to Responses/Messages and :970 renders Chat effort as DeepSeek's numeric score only. Open docs PR #172 describes the pre-#677 behaviour. The one item I would not merge without.
  6. LOW: chatml.rs:1408-1430 duplicates the push/finish block across compact although Harness (:412-437) exists; decode.rs:2540-2557 and :2621-2638 closures differ only in the frontend triple.

Clean: the Candidate enum (tagged.rs:31-39) and its 12-line consumer (:336-347), the trait-default parse_candidate (:50-52), MiniMax's 2-line mapping, the single find_map alias lookup (decode.rs:184-193). No dead code, no new knobs or dependencies.

Open: whether the three mode flags had a future consumer (none found); whether the argument_tags EOS message change is acceptable; merge order vs #670, which conflicts in the same region.

Full report · Notes

Correctness and contracts

Reviewed PR #677's six changed files with their direct callers (request.rs effort ladder, frontend/mod.rs resolve_effort, tml.rs, inference.rs, docs/api.md, AGENTS.md, kani_proofs.rs). No concurrency, contention, or metric-span change exists in the diff; memory retention and EOS rejection semantics are preserved. Four Major and two Minor issues:

  1. Major — undocumented prompt shift (TMLv0): Chat reasoning_effort:"medium" now yields Effort::High with the raw string withheld (decode.rs:621-624, :684-686), and request.rs:521's ladder picks high first, so TMLv0 renders 0.9 instead of 0.7 (tml.rs:19-27, frontend/mod.rs:829-835). Disclosed only for "Jinja templates".
  2. Major — fix incomplete for "high": no normalized_chat_effort on that arm (decode.rs:625), so high still reaches the template verbatim and still 400s on templates that reject it (tests/frontend/qwen38.json:3089-3099).
  3. Major — quadratic rescan on the output hot path: Candidate::IncompleteValue loops and re-runs parse_candidate(&self.buffer[..end]) from offset 0 per literal inner closer (tagged.rs:306-347, with parsers restarting at the body head: argument_tags.rs:25-27, chatml.rs:105-109), up to K× up to 1 MiB inside the unchanged bound at tagged.rs:303-305.
  4. Major — docs contract unmet: AGENTS.md:230 requires docs/api.md; no docs file in the diff, and docs/api.md:960-965 still scopes named-level resolution to Responses/Messages.
  5. Minor — aliases read on every role (decode.rs:184-194), so a tool message with thinking/reasoning injects a stray content-less frame via inference.rs:303-311.
  6. Minor — public API break (Candidate + parse_candidate signature, tagged.rs:31-52) colliding with open PR #670's rewrite of the same functions.

Verified sound: main's None really did set in_json_string for every non-Some; EOS still rejects open values in all four dialects; MiniMaxXml's Complete mapping is a no-op (its CLOSE starts with the reserved sentinel); 1 MiB bound and Kani struct fields unchanged.

Open questions: whether the TMLv0 shift is intended; why high was left raw; merge order vs #670; docs follow-up vs #172.

Full report · Notes

Final review

Recommendation: Changes Requested

Both core problems are real—the three-state Candidate split in helios/src/output/ cleanly fixes literal closing tool tags inside non-JSON argument values without weakening EOS rejection or strict-tool validation, and the Chat Completions alias lookup preserves multi-turn reasoning history across reasoning_content, thinking, and reasoning. However, this PR should not merge as-is: withholding Chat "reasoning_effort": "medium" and mapping it to Effort::High silently shifts TMLv0 (Inkling 2) effort from 0.7 to 0.9 and breaks the existing in-repo golden test prompts_match_tml_renderers_token_for_token (tests/frontend/inkling2_tml.json:318-341). In addition, Candidate::IncompleteValue introduces an O(K·N) full-prefix reparse on the output presentation hot path, "high" remains unnormalized for Qwen3.8-style templates, and docs/api.md is not updated.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Chat "reasoning_effort": "medium" silently shifts TMLv0 (Inkling 2) effort from 0.7 to 0.9 and breaks the existing golden test prompts_match_tml_renderers_token_for_token
    • Location: helios/src/server/protocol/decode.rs:621-624, :684-686; helios/src/server/request.rs:515-527; helios/src/frontend/mod.rs:828-835; helios/src/frontend/tml.rs:19-35, :55-61; helios/src/server/request/tml_tests.rs:104-114; tests/frontend/inkling2_tml.json:318-365.
    • Verified behavior & impact: Because decode.rs:621-624 maps Chat "medium" to Effort::High and sets normalized_chat_effort = true, :684-686 withholds "medium" from options.template. request.rs:515-527 then resolves Effort::High with candidates = &["high", "medium"] via Frontend::resolve_effort. For PromptEncoder::TmlV0 (frontend/mod.rs:829-834), tml::effort_level accepts both "high" (0.9) and "medium" (0.7), so "high" wins first and renders 0.9 instead of 0.7. This directly breaks the existing #[ignore]d golden test prompts_match_tml_renderers_token_for_token (tml_tests.rs:104-114), which feeds tests/frontend/inkling2_tml.json:318-341 ("name": "effort_medium", Chat "reasoning_effort": "medium") through Protocol::Chat and asserts token-for-token equality with effort = 0.7 (token 22, vs effort_high 0.9 token 24). It also silently shifts prompt tokens and prefix-cache keys for TMLv0 Chat clients without disclosure (the PR description scopes the medium → high note to Jinja templates only).
    • Note on non-fixes: Simply reordering Effort::High to &["medium", "high"] does not work—it would break tests/frontend/inkling2_tml.json:3383-3391 (equivalent_requests asserts Responses {"reasoning": {"effort": "medium"}} maps to effort_high = 0.9) and would regress GLM-5.3 itself, because resolve_effort (frontend/mod.rs:853-864) probes Jinja templates only via .render(...).is_ok(), and GLM-5.3's template does not raise on "medium" (it falls back to "max"), so accepted includes "medium".
    • Fix: Preserve native Chat "medium" on encoders that explicitly define a distinct "medium" level—for example, keep top-level Chat "medium" in options.template (or pass it as an advisory effort that TmlV0 resolves to "medium" while encoders without native "medium" resolve to "high"), and add a unit test in decode::native_prompt_tests verifying Chat "reasoning_effort": "medium" through PromptEncoder::TmlV0 produces 0.7 while Responses {"reasoning": {"effort": "medium"}} still produces 0.9. (If maintainers instead explicitly want Chat "medium" to become 0.9 on TMLv0 as well, update tests/frontend/generate_inkling2_fixtures.py (not opened) and tests/frontend/inkling2_tml.json and disclose the TMLv0 breaking change in the PR description and docs/api.md.)

Should Fix

  1. Candidate::IncompleteValue introduces an O(K·N) full-prefix reparse on the output presentation hot path

    • Location: helios/src/output/tagged.rs:303-348, helios/src/output/argument_tags.rs:25-98, helios/src/output/chatml.rs:98-188, helios/src/output/gemma_call.rs:123-167.
    • Verified behavior & impact: On main, TaggedTools::push called parse_candidate at most once before switching to linear JSON quote-skipping (in_json_string = true). With Candidate::IncompleteValue => {}, the loop in tagged.rs:306-348 advances self.search_from past each literal closing tag and re-invokes D::parse_candidate(&self.buffer[..end], &self.tools) from byte 0 of self.buffer on every subsequent inner closing tag. All three dialects restart from the beginning of body, re-parsing and re-validating every completed argument and rescanning the entire open value up to end each time. Within the 1 MiB buffer bound (tagged.rs:303-305), an argument containing K occurrences of a 12-byte </tool_call> (worst case K ≈ 87,381) triggers triangular O(K·N) scanning (~K·N/2 ≈ 4.5 × 10^10 byte inspections, ~45 GB of scanning plus repeated JSON/schema validation) on the Tokio response presentation task—the exact same O(k·n) rescan pattern flagged on #670.
    • Fix: Avoid re-running parse_candidate until the currently open value can actually terminate—analogous to how InJsonString skips directly to the next unescaped " in TaggedTools::push (tagged.rs:307-323). For example, let IncompleteValue carry or advance to the dialect's value terminator ("</arg_value>" for ArgumentTags, "<|\"|>" for GemmaCall, next parameter_end/parameter_start/</function> for FunctionTags) so scanning an open value is O(N) total across the 1 MiB buffer. If this adds a state field to TaggedTools, update helios/src/output/tagged/kani_proofs.rs:100-110 and verify with cargo kani per docs/design-review.md:221-251.
  2. Chat "high" (and "max") are left unnormalized, leaving the same HTTP 400 open on Qwen3.8 templates

    • Location: helios/src/server/protocol/decode.rs:625-626, :684-686; helios/src/server/request.rs:515-527; tests/frontend/qwen38.json:3089-3099.
    • Verified behavior & impact: decode.rs:625-626 maps "high" and "xhigh" | "max" to Effort::High / Effort::Max without setting normalized_chat_effort, so :687-688 still copies them verbatim into options.template and request.rs:515 skips frontend.resolve_effort. While keeping "xhigh" raw is necessary so DeepSeek V4.1 retains score 75 instead of max's 100 (verified at decode.rs:2650-2654 and helios/tests/deepseek_requests.rs:460), leaving "high" (and "max") raw causes strict templates like Qwen3.8 (tests/frontend/qwen38.json:3089-3099: "Unexpected reasoning effort high. Supported types are xhigh (default), medium, and low.") to keep returning HTTP 400. Normalizing "high" and "max" through resolve_effort still resolves to "high" / "max" on DeepSeek V4/V4.1, GLM-5.3, Kimi K3 (helios/tests/fixtures/templates/kimi3/chat_template.jinja:83-85), and TMLv0, while resolving to "medium" / "xhigh" on Qwen3.8.
    • Fix: Include "high" and "max" in Chat normalization (leaving "xhigh" raw so DeepSeek V4.1 preserves 75 vs 100) and add a Qwen-vocabulary (['low', 'medium', 'xhigh']) test case in decode::native_prompt_tests.
  3. Update docs/api.md for the observable API behavior changes (AGENTS.md:230)

    • Location: docs/api.md:539-547, :599-628, :960-995; AGENTS.md:230.
    • Verified behavior & impact: AGENTS.md:230 requires updating the relevant docs/api.md sections when changing API behavior, and no file under docs/ is modified. docs/api.md:960-987 currently scopes named effort resolution strictly to Responses and Messages and documents Chat reasoning_effort only as the DeepSeek numeric score; it does not mention Chat named-level normalization, nested reasoning.effort on Chat, message-level thinking/reasoning aliases and their non-string HTTP 400 validation, or that literal outer closing tool tags inside non-JSON argument values remain argument text. Open docs PR #172 also edits this same GLM effort paragraph with pre-#677 behavior.
    • Fix: Update docs/api.md:960-995 and the tagged tool parsing section (:599-628) in this PR to document the exact shipped behavior, and coordinate wording/merge order with #172.

Subtract / Simplify

  1. Delete the redundant allow_incomplete_value / eos incomplete-value mode flags and dead match arms across all three dialects

    • Locations: helios/src/output/chatml.rs:91-104, :168-174; helios/src/output/gemma_call.rs:123-128, :150-159, :175-193; helios/src/output/argument_tags.rs:85-91, :111-128.
    • Detail: In chatml.rs and gemma_call.rs, non-streaming callers (parse and parse_eos) pass allow_incomplete_value = false, so the inner helpers return Err(...) directly and make the Candidate::IncompleteValue arms in parse_tool (chatml.rs:94) and GemmaCall::{parse,parse_eos} (gemma_call.rs:178,189) completely unreachable while duplicating identical error strings. Deleting allow_incomplete_value in both files and unconditionally returning Ok(Candidate::IncompleteValue) preserves exact behavior and exact error messages. In argument_tags.rs:85-91, parse_body similarly branches on if eos even though parse (:115) and parse_eos (:124) already map Candidate::IncompleteValue (making :124's IncompleteValue arm unreachable; note eos itself is still needed for :32, :41, :44). Always returning Ok(Candidate::IncompleteValue) at :86 (and mapping it to "unterminated GLM argument value" or "incomplete GLM tool call" in parse_eos) unifies all three dialects onto one rule.
  2. Reuse present() and replace the mutable normalized_chat_effort flag in decode.rs

    • Location: helios/src/server/protocol/decode.rs:38-40, :590-592, :606-629, :684-686.
    • Detail: :590-592 open-codes !present(body, "reasoning_effort") && present(&body["reasoning"], "effort") despite present() already existing at :38-40. Likewise, let mut normalized_chat_effort = false; mutated across three separate match arms can be replaced by a single immutable let withheld_chat_effort = ...; computed once before the :677 loop.

Nits

Dropped on verification

Full report Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes decide malicious: all_clear (100%): No malicious content found

explore

Author: brandonmmusic-max (CONTRIBUTOR; Discord "Brandonmusic") Motivation: Chat Completions clients send reasoning settings and reasoning history that the server silently dropped or forwarded raw, so models either lost context between turns or ran at the wrong effort (or rejected the request). Separately, a literal tool-closing tag appearing inside an argument made the parser never finish the call, returning HTTP 500. Scale: +1089 / −80 lines in 11 files (was +791 / −59 in 6 files at the previous head) Proposal:

Full report · Notes

Classify intake

Selected: triage:review, priority:P2, bug, performance, area:api, model:inkling-small

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +performance, +model:inkling-small

Subtraction and simplicity

Subtraction/Simplicity review of PR #677 (head c897437): the parser half is lean; the effort half carries all the removable complexity.

  1. scan_value_end's trait default Ok(0) (helios/src/output/tagged.rs:56-63) is speculative generality — only 3 dialects ever emit IncompleteValue and all override it — and wrong: push treats Ok as "value ended" (tagged.rs:350-361), so it would spin forever and the 1 MiB bound (tagged.rs:329) can't catch it. Fix: default Err(0), or drop the default.
  2. Chat effort normalization duplicates its six-name vocabulary (decode.rs:677-682 vs the match at :613-629) and its Chat && !chat_nested_effort predicate four times (:596-598, :622, :627, :677). Collapse to one chat_top_level binding and a match returning (native, normalized).
  3. Effort::Medium (inference.rs:121-122, ladder request.rs:521) is a shared-enum variant whose only distinguishable consumer is TmlV0, since resolve_effort restricts other encoders to low|high|xhigh|max (frontend/mod.rs:836-841). Expressible by keeping Chat medium at High and preferring "medium" for TmlV0 in request.rs.
  4. The Candidate→Err mapping is hand-copied six times (gemma_call.rs:166-188 twice, argument_tags.rs:107-113 & :124-131, chatml.rs:129-134); one Candidate::into_calls method deletes ~30 lines.
  5. ChatML has two implementations of "where the parameter value ends" (chatml.rs:30-47 vs :197-208); fold into one find_value_end, and share the parameter prefix ladder behind possible_parameter_start/_end (chatml.rs:85-119).

Lower priority: ~250 lines of triplicated parser test scaffolding (argument_tags.rs:766-935, chatml.rs:1426-1580, gemma_call.rs:367-469); the PR still bundles two independent defects.

Open: whether Err(0) is the intended no-override semantic; whether the TMLv0 medium preference belongs in request.rs rather than a shared variant; whether the possible_parameter_* duplication is deliberate. Kani/mutants and the stated test counts unverified (not run).

Full report · Notes

Correctness and contracts

#677 (head c897437) is close to mergeable, but two Major correctness/robustness issues remain in the new code.

Major — scan_value_end fails open. The trait default returns Ok(0) (helios/src/output/tagged.rs:56–63) and push treats Ok as "value ended" and adds nothing (:350–361), so any dialect returning IncompleteValue without overriding it silently reverts to one full body re-parse per inner closing tag (O(N·K)) — no compile error, no test or Kani failure. It is not a hang (:377 always advances), so the dossier's "spins forever" wording should be corrected. Fix: make the method required, or treat advance == 0 as Err.

Major — effort resolution is a sentinel-render heuristic. helios/src/frontend/mod.rs:863–879 drops medium when its render equals the __flare_unknown_effort__ render, so a template clamping unknowns to a medium default loses a level it lists; Effort::Medium then resolves to "high" (request.rs:521). The acting path is untested (the only vocabulary test, frontend/mod.rs:1742–1777, uses raise-on-unknown templates where the filter never fires) and undocumented (docs/api.md:988–991).

Minor — unknown/non-string top-level Chat reasoning_effort is forwarded verbatim (decode.rs:606–607, 627, 677–682) while the nested spelling 400s, contradicting docs/api.md:984–987 and charter #417.

Minor — top-level vs nested medium yields different prompts for the same Chat request on Inkling 2 (decode.rs:622–625, request.rs:521–522).

Minor — truncation inside an open argument value now omits the call silently on OutputLimit/UserStop (tagged.rs:283–296), documented at docs/api.md:636–638 but missing from the PR's compatibility notes.

Tests — no Jinja Effort::Medium test, no unknown top-level effort test, kani_proofs.rs (not opened) not executed, stress tests don't pin asymptotics.

Sound: no wire/graph contract change (inference.rs:117–125, 153), 1 MiB bound and drain discipline intact (tagged.rs:328–331, 397, 416), strict rejection and EOS Reject preserved (:292), six probes run once per Frontend behind OnceLock — no hot-path contention or metric-span change.

Open: startup probe cost; whether to require scan_value_end; docs PR #172 collision.

Full report · Notes

Re-review

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, 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, and docs/api.md plus Kani proofs are updated to match. No new correctness, safety, or hot-path regressions were introduced; the remaining items below are optional follow-up cleanups and minor nits.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

  1. Fail-closed default for ToolDialect::scan_value_end (helios/src/output/tagged.rs:61-63): Every current dialect that emits Candidate::IncompleteValue (ArgumentTags, FunctionTags, GemmaCall) overrides scan_value_end, while MiniMaxXml and TaggedJson never emit IncompleteValue. Returning Err(0) instead of Ok(0) in the trait default keeps non-IncompleteValue dialects untouched while ensuring any future IncompleteValue dialect fails immediately in its first functional test instead of silently falling back to O(K·N) reparsing.
  2. Deduplicate Chat effort predicate and normalized-name list (helios/src/server/protocol/decode.rs:596-629, 677-682): protocol == Protocol::Chat && !chat_nested_effort is repeated at :622 and :627, and the six withheld level names at :681 mirror the match arms at :614-626 (excluding "xhigh"). Binding let chat_top_level = protocol == Protocol::Chat && !chat_nested_effort; once and returning (native, withhold) from the effort match (with "xhigh" returning (Some(Effort::Max), false) on chat_top_level) removes the duplicated list and prevents future drift.
  3. Share < parameter-boundary scan in ChatML (helios/src/output/chatml.rs:30-47, 197-208): FunctionTags::scan_value_end and parse_tool_candidate walk tail.match_indices('<') with the same parameter_end / parameter_start / </function> predicates. Extracting a single fn find_value_end(tail: &str) -> std::result::Result<(usize, usize), usize> lets scan_value_end be find_value_end(tail).map(|(end, consumed)| end + consumed) and parse_tool_candidate reuse it directly, eliminating duplicate logic and drift risk.
  4. Optional Candidate::into_calls helper (helios/src/output/argument_tags.rs:108-112, 125-130, chatml.rs:130-134, gemma_call.rs:167-171, 183-187): Five parse/parse_eos sites repeat the three-arm Candidate match to convert IncompleteValue/InJsonString into errors; a small helper method on Candidate would trim ~15-20 lines.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: yes (89%): Testing will add considerable value with the code. It is ready to merge and the tests will validate and improve confidence on hardware we have available for testing.

Pre Test Report

Hardware test plan — PR #677 (fix/helios-glm53-tool-and-reasoning, head c897437)

1. What is being validated

Two independent fixes in one branch:

Half Files Claimed behavior
Tagged tool-call parsing helios/src/output/tagged.rs (Candidate{Complete,InJsonString,IncompleteValue} :31-37, ToolDialect::scan_value_end :61-63, TaggedTools::in_value), argument_tags.rs (GLM <arg_value>), chatml.rs (ChatML <parameter=…>, scan_value_end :30-47), gemma_call.rs (`< "
Chat decode / effort decode.rs (:181-199 assistant-only reasoning aliases, :593-682 effort), inference.rs:121-122 (not opened) (Effort::Medium), request.rs:521 (&["medium","high"]), frontend/mod.rs:843-880 (sentinel __flare_unknown_effort__ template probe) thinking/reasoning aliases on assistant messages (non-string → 400); nested reasoning.effort on Chat; top-level none/minimal/low/medium/high/max normalized against the prepared vocabulary and withheld from options.template; xhigh and numeric scores pass through raw.

2. Bottom line on GPU spend

Neither half needs a GPU to be validated, and there is no speedup to measure against main.

So: Phase 0 (CPU) carries the validation. Phase 1 on cn7 (~45 min GPU) confirms the two user-visible changes on real templates. Phase 2 on cn5 (~20 min) is optional.

3. Host → what it can actually test

Host Usable for #677?
cn7 (1×GB10, arm64, 10 CPU, 60 GiB RAM, 16 GiB scratch) Primary. Has nvidia/Qwen3.8-27B-NVFP4 (strict low/medium/xhigh template → high/max 400 regression), MiniMaxAI/MiniMax-M3.1-Flash (touched MiniMaxXml), and nvidia/GLM-5.3-Flash-NVFP4 (the <arg_value> headline case + fallback-effort template). One GPU, so serve one core at a time.
cn5 (4×RTX PRO 6000, amd64, 48 CPU, 125 GiB RAM) Optional. Only tool-bearing model is nvidia/GLM-5.3-Flash-NVFP4 (also on cn7). No Qwen, no Gemma, no MiniMax. Use only if the GLM dialect is somehow left unexercised on cn7.
Missing everywhere No Inkling 2 (TMLv0) core and no DeepSeek core on either host. The medium→0.7 (Chat) vs 0.9 (Responses) contract and DeepSeek high=75 vs max=100 are therefore CPU-only checks. State this in the test record — do not imply hardware covered them.

4. Phase 0 — CPU, no GPU lease (~40 min). Do this first; if it fails, stop.

# 1. pin templates
.venv/bin/python tests/frontend/prepare_templates.py --output "$FLARE_TEST_TEMPLATE_DIR"

# 2. full crate
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) \
  --features runtime-core,server 2>&1 | tee /tmp/677-unit.log
#    PASS: 0 failed; record exact passed/ignored and compare with the PR's 1,841/47

# 3. the parser tests, by name
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) \
  --features runtime-core,server literal_closing_tool_tag
#    plus plain_closing_tool_tag_in_element_text, split_streams_preserve_reasoning

# 4. TMLv0 golden + effort normalization
FLARE_INKLING2_TEST_SNAPSHOT=<dir with tokenizer.json (not opened)> \
  cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) \
  --features runtime-core,server -- --ignored tml_tests        # PASS: 6 passed, includes
                                                              # prompts_match_tml_renderers_token_for_token
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server \
  chat_normalizes_reasoning_effort_across_glm_qwen_tml_and_deepseek
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server \
  chat_preserves_assistant_reasoning_aliases_across_jinja_and_native_encoders

# 5. linearity timing (the PR's only quantitative claim) — release build, 40,000-tag case
cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server \
  -- --nocapture literal_closing_tool_tag
#    PASS: single-digit milliseconds, not seconds

Optional but recommended (author disclosed it was not run): cargo kani on helios/src/output/tagged/kani_proofs.rs (not opened) — in_value was added to eos_decision (kani_proofs.rs:99-136 (not opened)) and per docs/verification.md:56-84 an unexecuted proof is not evidence. If Kani is unavailable on the machine, record it as an unrun check, not a pass.

5. Phase 1 — cn7, ~45 min GPU (one core at a time)

# rebuild Flare from PR head; a serving-only Rust change needs NO re-export (AGENTS.md:273-278)
cargo build --release --manifest-path flare-cli/Cargo.toml (not opened)
flare-cli/target/release/flare run <qwen3.8-27b-nvfp4 core> --gpus 0

1. Effort matrix (Qwen3.8, non-streaming, max_tokens: 8, thinking on). Send reasoning_effort = low, medium, high, xhigh, max, minimal.

2. Reasoning aliases (one script, 4 requests against the same service). Base an assistant turn on a tool call, follow with a tool result.

3. MiniMax regression (2 requests). Serve MiniMaxAI/MiniMax-M3.1-Flash: one plain completion and one tool call. This only needs to confirm the MiniMaxXml parse_candidate → Complete mapping (minimax_xml.rs:200-202) did not disturb its namespace-prefixed closer; the synthetic proof is minimax_xml.rs:443-483.

4. Tool-call smoke for the headline fix (Qwen's ChatML dialect), non-streaming and stream: true separately. Declare one function with a single string parameter and ask: "Call grep with pattern exactly a</tool_call>b."

5. EOS rejection. Same tool, max_tokens: 16, prompt inviting a long argument. PASS: any truncated call is not returned as a tool call (docs/api.md:636-638).

6. Regression sweep: FLARE_API_TEST_URL=http://127.0.0.1:8000 .venv/bin/python -m pytest tests/server/test_protocols.py -q (idle service) and pytest tests/server/test_qwen38_dense_dflash.py (not opened) -q.

6. Phase 2 — cn5, ~20 min, only if the GLM dialect is unexercised

GLM-5.3-Flash-NVFP4 is also on cn7 (1 GPU is enough for TP1), so prefer cn7 and skip cn5 rather than paying 4-GPU load time. If used: flare-cli/target/release/flare run <glm-5.3-flash-nvfp4 core> --gpus 0, then

7. Not testable on this hardware, and not worth GPU time

8. Time budget

Phase Where GPU time Wall clock
0 any CPU host / cn5 48-CPU job 0 ~40 min
1 cn7 ~45 min ~75 min incl. core load
2 (optional) cn5 ~20 min ~40 min incl. core load

9. Findings a reviewer should carry into the test record

  1. The PR is mergeable, with nits per re-review at head c897437: all round-1 blockers fixed (TMLv0 medium preserved via Effort::Medium; linear scan_value_end; high/max normalized for Qwen; docs/api.md:975-995 and :621-625 updated; rebased over merged #670). Two non-blocking items remain: the fail-open Ok(0) default and the sentinel heuristic.
  2. Testing will not change the merge decision — it will confirm the two user-visible changes work end-to-end on a strict template (Qwen3.8) and on the tool parser with a real model. That is a worthwhile ~45 minutes on cn7; it is not worth 4 GPUs for hours on cn5.
  3. No speedup claim survives measurement: nothing to benchmark against main, since main fails the input outright. Frame the result as "the HTTP 500 is gone and the argument is preserved", plus the CPU timing showing linear scan.
  4. Report gaps honestly in the result: no Inkling 2 and no DeepSeek hardware, so those contracts were validated only by the CPU golden/unit tests; cargo kani unrun unless you run it in Phase 0.

Full report · Notes

Discord Test Request

Deliverable — ready-to-paste Discord post

## Recommendation: Test
High confidence. Both fixes are already covered by CPU-only tests in the repo; hardware only confirms the two user-visible changes end-to-end.

## Hardware Required
- cn7 (1× GB10): serve Qwen3.8-27B-NVFP4, GLM-5.3-Flash-NVFP4, MiniMax-M3.1-Flash — one core at a time
- Any CPU host, no GPU lease, for the ~40 min test suite (this is where the real validation happens)
- Skip cn5 (4 GPUs) — the only model it has that matters, GLM-5.3, also runs on cn7

## Justification
- The headline bug is that `main` returns HTTP 500 on a literal `</tool_call>` inside a tool argument; any GPU run either reproduces the 500 or proves it gone — no benchmark needed.
- Effort levels `high`/`max` currently 400 on strict templates (Qwen3.8), and `medium` silently falls through to `max` on GLM; a few requests confirm both now resolve correctly.

## Estimated Time to Complete
~2 hours total: ~40 min CPU-only (blocking — stop if it fails) + ~75 min wall clock on cn7 (~45 min GPU, rest is core load).
-----

How I built it

Source material: the hardware test plan for PR #677 (fix/helios-glm53-tool-and-reasoning, head c897437), plus the PR's own description and re-review.

I checked the plan's load-bearing claims against the repo at the PR head so the post does not overstate anything:

Simplifications I made for the Discord audience

Caveats to state in the eventual test record (not the post)

No Inkling 2 (TMLv0) or DeepSeek core exists on cn7 or cn5, so the medium→0.7 (Chat) vs 0.9 (Responses) contract and DeepSeek high=75 vs max=100 were validated only by CPU golden/unit tests — do not imply hardware covered them. cargo kani on tagged/kani_proofs.rs (not opened) (updated for in_value in eos_decision) was disclosed as unrun by the author; run it in Phase 0 or record it as an unrun check, not a pass.

Full report Human Approval: Do you approve this test? → No answer in time.

Deliverable — ready-to-paste Discord post

## Recommendation: Test
High confidence. Both fixes are already covered by CPU-only tests in the repo; hardware only confirms the two user-visible changes end-to-end.

## Hardware Required
- cn7 (1× GB10): serve Qwen3.8-27B-NVFP4, GLM-5.3-Flash-NVFP4, MiniMax-M3.1-Flash — one core at a time
- Any CPU host, no GPU lease, for the ~40 min test suite (this is where the real validation happens)
- Skip cn5 (4 GPUs) — the only model it has that matters, GLM-5.3, also runs on cn7

## Justification
- The headline bug is that `main` returns HTTP 500 on a literal `</tool_call>` inside a tool argument; any GPU run either reproduces the 500 or proves it gone — no benchmark needed.
- Effort levels `high`/`max` currently 400 on strict templates (Qwen3.8), and `medium` silently falls through to `max` on GLM; a few requests confirm both now resolve correctly.

## Estimated Time to Complete
~2 hours total: ~40 min CPU-only (blocking — stop if it fails) + ~75 min wall clock on cn7 (~45 min GPU, rest is core load).
-----

How I built it

Source material: the hardware test plan for PR #677 (fix/helios-glm53-tool-and-reasoning, head c897437), plus the PR's own description and re-review.

I checked the plan's load-bearing claims against the repo at the PR head so the post does not overstate anything:

  • helios/src/output/tagged.rs:31-37 — Candidate { Complete, InJsonString, IncompleteValue } exists as described; scan_value_end default Ok(0) at :61-63; TaggedTools::push linear scan at :350-361 and in_value = true on IncompleteValue at :406.
  • All three IncompleteValue dialects do override scan_value_end (argument_tags.rs:117 (not opened), chatml.rs:30 (not opened), gemma_call.rs:176 (not opened)), so the fail-open default is unreachable today — consistent with the plan's "code-review item, not hardware testable".
  • helios/src/server/request/tml_tests.rs:102-114 — the Inkling 2 golden test prompts_match_tml_renderers_token_for_token is #[ignore]d pending FLARE_INKLING2_TEST_SNAPSHOT, matching the plan's Phase 0 step 4.
  • PR re-review at head c897437 records 0 blockers / 0 should-fix and "Ready To Merge"; the plan correctly frames testing as confirmation, not a merge gate.

Simplifications I made for the Discord audience

  • Dropped the O(K·N) → O(N) framing from the justification: on main the input does not parse at all, so there is nothing to benchmark against; the post instead names the concrete user-visible symptom (HTTP 500 on a literal closing tag) and the concrete regression (high/max → 400, medium → max).
  • Collapsed the "missing hardware" caveat (no Inkling 2 or DeepSeek core on either host) out of the post — it is a test-record honesty note, not a reason to test. Flagged separately below.
  • Reduced hosts to what is actually useful: cn7 for the ~45 min GPU confirmation, CPU host for the blocking suite, cn5 explicitly marked skip.

Caveats to state in the eventual test record (not the post)

No Inkling 2 (TMLv0) or DeepSeek core exists on cn7 or cn5, so the medium→0.7 (Chat) vs 0.9 (Responses) contract and DeepSeek high=75 vs max=100 were validated only by CPU golden/unit tests — do not imply hardware covered them. cargo kani on tagged/kani_proofs.rs (not opened) (updated for in_value in eos_decision) was disclosed as unrun by the author; run it in Phase 0 or record it as an unrun check, not a pass.