Case file — PR #677 (helios): Chat Completions reasoning aliases, effort normalization, literal closing tool tags
PR: https://github.com/NVIDIA/hyperflare-inference/pull/677
Author: brandonmmusic-max (CONTRIBUTOR; Discord "Brandonmusic")
State: open, ready for review, 6 files, +791 / −59, head f439f74, base main@1fbcc3c9; no comments, no reviews, no labels, no CI checks on head.
Key findings
Facts a reader could not get from the description:
- An undeclared behaviour change on TMLv0 native encoders. The description discloses the
medium → highremap only for "Jinja templates distinguishing medium from high". In practice, Chat"reasoning_effort": "medium"now setsEffort::High(helios/src/server/protocol/decode.rs:621-624) and the raw string is withheld from the template (decode.rs:684-686);request.rs:515-527then resolvesHighagainst the TMLv0 vocabulary and pickshigh(["high","medium"]), so the rendered effort on Inkling 2 / TMLv0 models moves from 0.7 to 0.9 (helios/src/frontend/tml.rs:19-27mapsmedium→0.7,high→0.9). - The fix is incomplete for
"high"."high"is not normalized (onlynone/minimal/mediumsetnormalized_chat_effort), so a Chat"high"still reaches the template verbatim and still fails on templates that reject it — e.g. Qwen3.8's pinned template: "Unexpected reasoning effort high. Supported types are xhigh (default), medium, and low." (tests/frontend/qwen38.json:3089-3099). docs/api.mdis not updated, although it is the specification for both halves (:955-995reasoning controls,:596-628/:539-547tagged-tool EOS rules) andAGENTS.md:230requires API-behaviour changes to update it. Open docs-only PR #172 currently records the pre-#677 GLM behaviour (medium→Max).- Direct collision risk with open PR #670 (lukealonso, opened ~10 h before #677), which rewrites the same
ToolDialect/TaggedTools/push/parse_candidateregion ofhelios/src/output/tagged.rsto carry contract-suppliedopen/closedelimiters. Merge order is unsettled (#670 has red CI and three blockers). - Two independent fixes bundled in one PR (commits
0b042e56decode,f439f744output parser) — maintainers ask for exactly this split on other PRs (e.g. #670's review). - The strongest evidence is external. SM120 GPU serving, BFCL v4 and
agentic_suite.py(not opened) results have no harness, command, core id or log in-repo (agentic_suite/BFCLgrep returns nothing). The new Rust tests, by contrast, are self-contained and do back the behavioural claims.
1. The change
Two unrelated fixes on one branch fix/helios-glm53-tool-and-reasoning:
(A) Decode — reasoning aliases (decode.rs). main decode.rs:184-190 read only reasoning_content and rejected non-string values. At head, chat_messages reads the first non-null of reasoning_content, thinking, reasoning across roles and errors naming the offending key (decode.rs:184-195). Consequence: a non-string thinking/reasoning field (e.g. an Anthropic-style {"type":"thinking",...} object echoed into a Chat message) is now an HTTP 400 where it was previously ignored — disclosed as compat note (a).
(B) Decode — effort normalization (decode.rs:590-638, :677-690). Chat now has an effort value: nested reasoning.effort when top-level reasoning_effort is absent/null (decode.rs:590-602), else the top-level string. none→enable_thinking:false, minimal→Effort::Minimal, medium→Effort::High, high→Effort::High, xhigh|max→Effort::Max (:608-629). When normalized or nested, the raw reasoning_effort is not copied into options.template (:684-686); chat_template_kwargs still extends afterwards and therefore still overrides (:694-701). Numeric Chat values are filtered out by .filter(|v| v.is_string()) (:601) and keep flowing through the template key loop, so DeepSeek numeric passthrough is preserved (test asserts numeric 50 ≡ low, decode.rs:2645).
(C) Output — three-state candidate (helios/src/output/). ToolDialect::parse_candidate changes from Result<Option<Vec<(String,String)>>> to Result<Candidate> with Complete | InJsonString | IncompleteValue (tagged.rs:31-39; default impl tagged.rs:49-52). TaggedTools::push sets in_json_string only on InJsonString (tagged.rs:343-345) and simply keeps scanning on IncompleteValue (:346), so an inner literal </tool_call> / <tool_call|> no longer terminates the call body. The 1 MiB bound (tagged.rs:303-305) and eos_decision (tagged.rs:257-271) are unchanged: an unclosed value still Rejects at EOS via !confirmed. ArgumentTags (CLOSE "</tool_call>", argument_tags.rs:109), ChatML parse_tool_candidate (chatml.rs:21) and GemmaCall (gemma_call.rs:173) return IncompleteValue in streaming candidate evaluation while direct parse/parse_eos still error; MiniMaxXml maps to Complete (minimax_xml.rs:194, 200-202) because its closer starts with a reserved NAMESPACE sentinel. Untouched dialects: dsml.rs (not opened), xtml.rs (not opened), tml.rs, recipient.rs (not opened), pipeline.rs (not opened).
Tests added: GLM every two-part UTF-8 split + single-character streaming (argument_tags.rs:759-912), ChatML and CompactChatML (chatml.rs:1390-1514), Gemma (gemma_call.rs:370-449), MiniMax (minimax_xml.rs:443-485), and two decode tests (decode.rs:2429-2524, :2526-2656).
Scale/placement: 6 files, all under helios/src; ~465 of the 791 added lines are tests. No core format, proto, config or dependency change.
Undocumented deltas in addition to Key findings 1–2: an unknown nested reasoning.effort string now errors (decode.rs:627-628) while an unknown top-level string still passes through to the template — an asymmetry the description does not spell out. There is no linked issue on either half.
2. The why
- Multi-turn reasoning loss: clients storing prior reasoning under
thinkingorreasoninghad it silently dropped by the Chat decoder, so tool loops lost context. Asserted with prompt-token evidence (509/509/509) in the description, but no linked issue. - Effort mismatch: raw
none/minimal/mediumreachedoptions.templateon Chat (maindecode.rs:655-660) and were rejected by strict encoders —frontend/deepseek.rs:191-219rejectsmedium,frontend/tml.rs:30-31rejectsminimal— or, for GLM-5.3 whose template only acceptslow/highand otherwise falls back tomax, ran at maximum effort.docs/api.md:961-969documents named-level resolution for Responses/Messages only; Chatreasoning_effortis documented only as the DeepSeek numeric score (:970-987). - The underlying resolution machinery exists:
request.rs:515-527inserts a resolved level fromFrontend::resolve_effort(frontend/mod.rs:828) using per-Effort candidate ladders (request.rs:518-523). The Chat gap was thatoptions.effortwas never set for Chat (maindecode.rs:587-616handled Responses and Messages only). - Tagged-tool HTTP 500: on main, any non-
Somecandidate setin_json_string, so the call never completed and an inner closer produced an unterminated-value error. The description reports it as reproduced on GLM-5.3 hardware (pattern="</tool_call>"in an<arg_value>), not reproducible in-repo.
Community demand/precedent: closed issue #25 ("Translate xhigh reasoning for deepseek v4.1 flash") is the same request class — harnesses send a level the template doesn't accept, users asked Flare to translate rather than reject "like vllm"; mark-yong's resolution comment attributes the ladder to /v1/responses and /v1/messages only, i.e. it explicitly leaves the Chat gap open. docs/TODO.txt:188-191 holds an adjacent open question about configurable default request parameters (server defaults, not per-request normalization); nothing in TODO covers either of #677's defects.
3. Related work
- #670 (open, lukealonso) "parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser" — rewrites
helios/src/output/tagged.rs(+65/−33) andargument_tags.rs, adding contract-suppliedopen/closetoToolDialect/TaggedOutput/TaggedTools: the same functions #677 changes. Semantics look compatible; textual conflicts likely. #670 already has an Autobot finding about an O(k·n) prefix rescan in itsparse_candidatepath. Opened 2026-12-02 00:26, ~10 h before #677; red CI, three blockers. - #596 (merged 2026-11-29, lukealonso) — same files (
declared_value/parameter_value); #677 calls helpers from that lineage (super::tagged::container_parameter,strict_nonstring_raw,RawArguments/to_json_string). #677 is stacked on it. - #573 (merged, lukealonso) — introduced
parse_eosand the EOS rules; #677 preserves them and asserts so in tests. - #67 (merged, mark-yong) "Keep prose tool-tag mentions in function-tag and GLM output as text" — created
starts_call; documented atdocs/api.md:601-608. #677 complements it: a literal closer inside a started call now stays argument text. - #179 (merged, mark-yong), #418 (merged, jcartu, strict function-tool arguments incl.
argument_tags.rs/chatml.rs/tagged.rs), #167 (yatesdr), #228 (merged, Martin Vit) — the recent lineage of the same files; #677 is additive to all of them, reversing none. - #133 (closed issue) — live GLM-5.3 tool-parse rejections (
unterminated GLM argument key, duplicate argument names) closed as preparation-side, with original-el8 noting "Malformed tool calls from otherwise valid model output remain a separate parser/API concern" — the half #677 addresses. - #172 (open docs-only) — see Key finding 3.
- #457 (open, same author) —
output/tml.rs(not opened),grammar.rs(not opened): different files, no overlap; its Autobot review flagged the same missing-docs and unreproducible-agentic_suite.py(not opened) weaknesses. - No other open PR or issue covers Chat reasoning aliases or the literal-close-tag parse failure.
4. Recent activity in the touched areas
helios/src/output/tagged.rs, newest first:99339606(#596, Luke Alonso),2bdc8472(#573, Luke Alonso),0b09434d(#418, Joshua Cartu),9d1e0137(#179, Mark Yong),f76b517f(#228, Martin Vit),902c88e2(#167, yatesdr),5dd6723e(#162, brandonmmusic-max). Five changes in the three weeks before #677; the file is dominated by Luke Alonso.helios/src/server/protocol/decode.rs:cd1daa3e(#638, flare-autobot, 2026-12-01 — one day before the branch point),e4d8eb60(#615, Frosty40),85de9eae(Joshua Cartu),0b09434d(#418),ab606762(yatesdr),902c88e2(#167). High-churn, six authors in six weeks.- Branch is current: both #677 commits (
0b042e56,f439f744) sit directly on1fbcc3c9, and no default-branch commit since the branch point touches any of the six files. - #677 builds on #596/#573 and preserves their contracts; the live in-flight conflict is #670.
5. People
- Author: brandonmmusic-max, GitHub association CONTRIBUTOR, Discord "Brandonmusic". In-repo track record: #162 merged ("Drop reasoning close delimiter tokens from visible content", commit
5dd6723eintagged.rsancestry — same file, same topic), #154 merged; 4 closed + 5 open PRs in 180 days (#597 compiled forward sharing, #475 CheckpointOverlay, #458 Responses SSE, #457 TML headers/grammar). Not a priority contributor (charter names @voipmonitor, @original-el8, @lukealonso). - Area owners:
helios/srclast 180 days — Luke Alonso (236), Martin Vit (52), yatesdr house/49;output/*also Mark Yong, Joshua Cartu.decode.rsis shared across at least six authors. - Engagement on #677: none — no reviewer, comment, review or reaction.
6. Community
Zero comments, zero reviews, zero reactions, no labels. Opened 2026-12-02 10:57 and unmodified since intake. For comparison, other outside-contributor PRs in this repo (#575) received Autobot reviews within hours; #677 has none, which may be review lag rather than rejection. Two independent fixes are bundled with no reviewer note asking to split (the split request was made on #670).
7. Project fit (charter, AGENTS.md, roadmap)
- Aligns with "Support the documented Chat Completions, Completions, Responses, and Messages APIs" (charter Goals;
docs/api.md:596-628,:955-995are the contracts implemented). - Aligns with "Don't silently ignore API fields… either implement it according to the spec or reject it" — the PR stops forwarding
none/minimal/mediumverbatim and stops droppingthinking/reasoninghistory and nestedreasoning.effort. Note it still resolves by precedence (lower-precedence aliases ignored when a non-null higher one exists) and still forwards unknown top-level strings raw. - Aligns with "smallest footprint in shared code / no per-model branches": the
Candidateenum is shared-layer,MiniMaxXmlgets an explicit no-op mapping, no protobuf or core-format change (nohelios/proto/file in the diff). - Tension: "Bug fixes need to address the root cause" — the output half does; the decode half is compatibility normalization, and leaves
highunnormalized and TMLv0mediumshifted. - Tension:
AGENTS.md:230requiresdocs/api.mdupdates for API behaviour changes; no docs file is touched. The description does follow AGENTS.md's four-part format and records unrun checks (Kani, mutants). - Roadmap: neither defect appears in it; the charter asks merged work to address a maintainer request, roadmap item, reproducible bug, measured perf issue, or bad docs. The output half has a reproducible bug (claimed reproduced on GLM hardware); the decode half rests on description-only evidence.
- Nothing in this PR proposes new model recipes/aliases/formats, so the charter's model-recipe rule does not apply.
8. Claims and evidence
Backed by in-tree tests (code read, not executed): the two decode tests build their own byte-level tokenizer and literal templates (decode.rs:1104-1175), so they do not need FLARE_TEST_TEMPLATE_DIR; chat_normalizes_reasoning_effort_and_accepts_nested_reasoning_object (decode.rs:2526-2656) covers none/minimal/medium/high/xhigh/max against a GLM-style ['low','high'] else 'max' template, nested effort, nested-vs-top-level precedence, chat_template_kwargs override, rejection of {"effort":"bogus"} and {"effort":50}, and DeepSeek V4.1 equivalences; chat_preserves_assistant_reasoning_aliases_across_jinja_and_native_encoders (decode.rs:2429-2524) covers alias equality, null fallthrough, precedence and the named-key error. The output tests sweep all two-part splits and single-character streaming while asserting unterminated values still error at EOS and strict tools still validate.
Not backed in-repo: "Live SM120 GPU HTTP serving validation (GLM-5.3-Flash TP=2 and TP=4)", prompt_tokens 509/509/509, BFCL v4 multiple 94.50% (189/200), multi_turn_base 65.00% (130/200), agentic_suite.py (not opened) 24/24 — no harness, core id, command, or log; agentic_suite/BFCL appear nowhere in the tree. The pre-fix HTTP 500 is consistent with main's code but not reproduced in-repo.
Disclosed and true: Kani/mutants not run; helios/src/output/tagged/kani_proofs.rs is not in the diff and still constructs TaggedTools with the same fields (:100-110) and SymbolicDialect overriding only parse/parse_eos (:71-85), so the default parse_candidate yields Complete there — structurally unchanged, but only eos_decision/select_candidate bear on this change.
Unverifiable without running: the test-count claims (1,795→1,799 unit, 62 integration, flare 254, flare-cli 245) and the cargo check matrix.
9. Reach
- Clients: Chat clients echoing reasoning under
thinking/reasoningkeep it in the prompt (becomesPart::Reasoning, lowered into the template'sreasoning_content,server/inference.rs:323-332);none/minimal/mediumand nestedreasoning.effortnow return 200; non-string alias values now 400;mediumreaching a Jinja template becomes the resolved level; tool-call arguments containing a literal outer closer parse instead of failing. - Operators: no new config keys, flags, defaults, proto or dependency changes (
[server] thinking_token_budgetuntouched). Identical requests can render different prompts after upgrading (GLM-stylemedium→high; TMLv0medium0.7→0.9), which shifts prompt tokens — and therefore prefix-cache keys — for those requests. Previously exported cores stay loadable; no re-export needed. Operators pinning an older binary keep the old behaviour. - Docs left stale:
docs/api.md:955-995(no Chat named-level normalization, nothinking/reasoninghistory aliases, no non-string rejection),docs/api.md:539-547/:596-628(no statement that a literal outer closer inside a non-JSON value is argument text),:731-732(per-dialect closers). Open PR #172 would document the old GLM behaviour in the same region. - Tests: Rust unit tests only; no
tests/server/*or live-harness coverage, so CUDA-gated serving suites do not exercise either fix.
10. Process
Ready for review, not draft. Two commits, current with main. No CI checks on head, no reviewer assigned, no labels, no maintainer engagement. Author has recent adjacent merges (#162, #154) but is not a priority contributor, so the PR is judged on merits.
Open questions / not found
- Merge-order intent versus #670 (same functions in
tagged.rs): whether #677 should land first, be rebased onto #670, or wait. - Why
"high"was left unnormalized whenmedium/minimal/nonewere normalized; whether Qwen3.8-style templates rejectinghighare considered out of scope. - Whether the TMLv0
medium0.7→0.9 shift is intended (the description mentions only Jinja templates). - Whether a docs change is planned in this PR or a follow-up (AGENTS.md:230 requires one), and how #172 should be written after #677.
- Reproducibility package for the SM120/BFCL/
agentic_suite.py(not opened) claims (core id, command, log); the same gap was raised on the author's #457. - Commit bodies /
Signed-off-bytrailers and the design self-review acknowledgment could not be read with the available tools; no linked issue exists for either defect.