PR #615: helios: support thinking_token_budget for ContentHeaders and trim incomplete UTF-8 tails on cut

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/55cb24c0-cfea-4916-9de9-7152a67a6271

Opened by a workflow run, Nov 29, 2026 2:05 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: newjordan (FIRST_TIME_CONTRIBUTOR — first contribution in the repo, no prior PRs or issues in 180 days; Discord frosty40) Motivation: thinking_token_budget (per-request and [server]) has to be a hard cap, and it already returns HTTP 400 on models whose reasoning lives inside TMLv0 content-header frames (Inkling 2 Mini/Small), because the cut code only knew formats that start in plain reasoning or content. Separately, a hard token cap can land mid-character on byte-level BPE tokenizers, so the re-prefilled continuation prompt carries 1–3 dangling UTF-8 bytes before the forced close token. Scale: +562 / −31 lines in 6 files (production code ≈ +156/−25; 442 of the added lines are tests). Proposal:

Full report · Notes

Classify intake

Selected: triage:review, enhancement, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +enhancement, +area:api

Value Proposition

Value Proposition: PR #615 — thinking_token_budget for ContentHeaders + UTF-8 tail trim

Charter alignment — partly aligned, partly adversarial. The PR closes a real gap in a shipped feature: on TmlV0/ContentHeaders cores (Inkling 2 Mini/Small), a documented request field (thinking_token_budget, Anthropic thinking.budget_tokens) and the [server] thinking_token_budget default currently yield HTTP 400 or a bootstrap failure. That touches the charter's "support the documented Chat Completions, Completions, Responses and Messages APIs" goal and the "either implement the field per spec or reject it" rule, and it reverses no prior work (#167 902c88e2 deliberately rejected such formats). But the mechanism collides with "keep the runtime small and model-agnostic … no per-model special cases": tml_text_transition_tokens() hardcodes <|message_model|>/<|content_text|> in the request layer (request.rs:543-555) while the contract declares reasoning.open/close but no text opener. The UTF-8 half is a U+FFFD heuristic at one call site (runtime.rs:2129-2155), not a decoder fix — the same hazard survives on preemption and at the plain output limit, short of #397's "root cause" bar.

Novelty & status — genuinely additive; not obsolete, not superseded. No other open PR targets thinking_token_budget or ContentHeaders budgets; #615 widens #167's accept list rather than reversing it. Two live conflicts must be resolved: open #457 rewrites the very TmlOutput/content-header semantics the injected unnamed-model-header + content-kind-marker sequence depends on (it adds an EOS error for a header without content), and neither PR references the other; #582 is in flight on the same park path this PR edits.

Value vs maintenance cost — benefit real, evidence thin, scope understated. Beneficiaries: Inkling 2 Mini/Small users who can now hard-cap reasoning, plus every reasoning format that silently gains the trim. Evidence is CPU-only on synthetic tokenizers with no CI on the head commit; the central behavioural claim — that a real model continues in a text frame after <|message_model|><|content_text|> — is unexercised (FLARE_INKLING2_TEST_SNAPSHOT #[ignore] tests and live flare run not run). The description also omits three substantive effects: the trim drops up to 3 already-generated tokens for all formats, not just TMLv0; generated_tokens / usage.completion_tokens inflate by the injected tail (3 vs 1), shifting dashboards built on #541; and a user token-stop can truncate the tail mid-sequence, contradicting the "all-or-nothing" framing. runtime.rs is among the most contended files in the repo (20+ items in 180 days), and this adds per-token accounting plus up to 4 decodes per cut on the worker thread, unbenchmarked.

Verdict: Worth it with changes. Keep the review investment, but require: (1) real-checkpoint or live GPU evidence that the injected pair yields a text continuation rather than a second thinking frame; (2) scope the UTF-8 trim to the forced-cut case it claims (or fix it at the decoder) and test a non-TML format; (3) declare the text-opener markers in the contract instead of hardcoding them in request.rs; (4) an explicit resolution with #457 (and a rebase past #582); (5) documented accounting/stop-path semantics and the stale comments in runtime.rs:68-70 / docs/logprobs-design.md. If (1) or (2) cannot be delivered, this should be declined — a format-keyed special case on synthetic-only evidence is not worth the maintenance cost on that file.

No prompt-injection or instruction-override attempts were present in the PR text, dossier, or discovered activity.

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

Subtraction and simplicity

Subtraction/simplicity review of PR #615: production code is lean (no new config keys, flags, or dead code), but three real subtractions remain.

  1. ReasoningCut { close, close_tail } (runtime.rs:50-61) plus the include_tail re-check (runtime.rs:1962-1972) state "one token, sometimes two" twice; the re-check re-tests operands fixed at preparation, so it is dead defensive code — replace with one sequence: Vec<u32> (~25 lines gone).
  2. tml_text_transition_tokens() (request.rs:543-555) is a second, weaker lookup for ids prepare_output already resolved into OutputConfig.control_tokens (model/prompt.rs:315-328 → output/pipeline.rs:135 → tml.rs:25/29), and it is the PR's only per-format branch in helios request prep (charter #267/#334). Delete it.
  3. The UTF-8 trim (runtime.rs:2129-2155) is a 27-line U+FFFD heuristic with magic 8-token window, 3-token cap and up to 4 decode calls per cut on the worker thread, where token_bytes + str::from_utf8 (precedent: token_spans.rs:129-141) gives it exactly in ~8 lines — or drop it, since preemption (runtime.rs:2121) keeps the same hazard and the charter wants root-cause fixes (#397).
  4. New tests rebuild tokenizers that exist in the same file (decode.rs:2034-2042 vs renderer() at decode.rs:1035-1154) and paste CONTROL_MARKERS (tml.rs:41-44) in three places.
  5. Stale comment at runtime.rs:68-71 ("forced token" singular) and duplicate u64::from(1 + x.len() as u32) < idiom.

Open: does control_tokens always carry the TML markers when a request sends no tools (contract-declared TmlJson)? And is the token_bytes batch API exactly as sketched? Nothing was compiled; correctness items left to the contracts lens.

Full report · Notes

Correctness and contracts

Reviewed PR #615 (ContentHeaders thinking_token_budget + UTF-8 tail trim) across all six changed files and their direct callees. The request-preparation and accounting core is sound; the UTF-8 trim half has a scope defect and the "all-or-nothing" claim is false.

Findings:

  1. Major — the trim in Worker::park() is gated only on !appended.is_empty() (runtime.rs:2133), so it fires for every forced cut in every format, including grammar-constrained ones, while the tail injection it accompanies is grammar-gated (runtime.rs:1962-1965). Already-grammar-advanced, already-published tokens are silently deleted from the parking prompt (runtime.rs:2150), diverging grammar state from prompt history; docs/api.md:817-823 documents this only for TMLv0/ContentHeaders.
  2. Minor — the injected tail is not all-or-nothing: a user token stop matching <|message_model|> breaks the loop mid-sequence (runtime.rs:1973-1981), leaving TmlOutput in State::Header (tml.rs:272-284), contradicting the PR text.
  3. Minor — '\u{FFFD}' cannot distinguish a provisional replacement char from genuine content that byte-fallback tokenizers emit; the repo says so at token_spans.rs:92-93.
  4. Minor — the trim silently no-ops when the partial sequence reaches the 8-token window start (runtime.rs:2141-2153) although docs/api.md:821-823 promises it unconditionally.
  5. Minor — hidden tokens per cut go 1 → up to 3 in generated_tokens/usage (runtime.rs:1991-1999, 2063) while prompt_tokens does not follow and reasoning_budget_cuts_total semantics are unchanged.
  6. Minor — <|message_model|>/<|content_text|> hardcoded in the request layer (request.rs:543-555) though OutputPipeline already exposes them; charter model-agnostic friction.
  7. Minor — decoded history retains the trimmed tokens (runtime.rs:2157).

Verified sound: event-capacity bound, admission.rs context and extend_text monotonicity invariants, preemption path, no platform or wire/proto change, and the injected pair legally re-enters Body::Text. Tests cover the happy paths but none of the five edge cases above.

Open questions: no live Inkling 2 evidence that the injected pair keeps the model in a text frame; whether the format-agnostic trim is intended; interaction with #457's "header without content" EOS path; reliability of the U+FFFD heuristic on the real tokenizer.

Full report · Notes

Final review

Recommendation: Changes Requested

This PR cleanly closes a real feature gap by enabling thinking_token_budget (and [server] thinking_token_budget) on ContentHeaders cores, and its core accounting, output_event_capacity, prompt_metadata::extend_text, and TmlOutput state transitions are verified sound. However, changes are requested before merge for three verified issues: the UTF-8 tail trim in Worker::park() uses a '\u{FFFD}' decode heuristic that drops legitimately generated literal U+FFFD tokens and silently fails to trim when <= 3 tokens were generated since the last admission/preemption, tml_text_transition_tokens() duplicates already-resolved TML control tokens with a per-format branch in request.rs, and the central behavioral claim (that <|message_model|><|content_text|> keeps a real Inkling 2 model in a text frame) currently has synthetic-only evidence with no real-checkpoint or live GPU verification.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Replace the '\u{FFFD}' decode heuristic in Worker::park() with exact token-byte UTF-8 boundary checking and fix the unnecessary generated_len - 1 trim floor (helios/src/server/runtime.rs:2129-2155, helios/src/server/config.rs:281).
    • False positive on literal U+FFFD: Decoding a window and checking text.ends_with('\u{FFFD}') (runtime.rs:2136-2139) cannot distinguish an incomplete trailing UTF-8 byte prefix from a legitimately generated literal U+FFFD character ([0xEF, 0xBF, 0xBD])—an ambiguity the codebase already calls out in helios/src/server/token_spans.rs:92-93. A literal '\u{FFFD}' at the budget boundary is silently deleted from the continuation prompt.
    • Silent failure on small/post-preemption passes (generated_len <= 3): let max_trim = 3usize.min(generated_len.saturating_sub(1)) and end > window_start (runtime.rs:2141-2144) fail to trim whenever a budget cut occurs with 1–3 tokens generated since the last admission (for example, a request preempted with 2 budget tokens remaining that generates [0xE2, 0xAC] of a 3-byte char: generated_len = 2 -> max_trim = 1 -> trimming 1 token leaves [0xE2] which still ends in U+FFFD, so nothing is trimmed). The comment at runtime.rs:2131-2132 claims at least one generated token must be retained for extend_text, which is unnecessary: tokens.extend_from_slice(appended) runs at runtime.rs:2156 before extend_text (runtime.rs:2167-2168) with !appended.is_empty(), guaranteeing tokens.len() >= live.prompt_tokens + 1 > incoming.prompt.tokens.len(), and extend_text itself only requires after >= before (helios/src/model/admission.rs:26).
    • Fix: Use Frontend::token_bytes() (helios/src/frontend/mod.rs:1534, backed by helios/src/frontend/vocabulary.rs:11-45) on the trailing tokens and validate with std::str::from_utf8 (as in helios/src/server/token_spans.rs:129-141), trimming generated tokens at index >= live.prompt_tokens only when Utf8Error::error_len().is_none() (a true incomplete UTF-8 suffix, never a literal U+FFFD). Ensure frontend.prepare_token_bytes()? is called at bootstrap (helios/src/server/config.rs:281 currently gates it on model.max_top_logprobs != 0) so VocabularyBytes is never lazily built on the worker thread during a cut. Add regression tests for a literal U+FFFD token at the cut boundary and a 2-byte incomplete tail with generated_len == 2.
  2. Delete tml_text_transition_tokens() and resolve the TML text-frame opener from the already-validated output.control_tokens (helios/src/server/request.rs:384-393, 543-555).
    • Contract validation already enforces the biconditional ToolParserKind::TmlJson <=> ReasoningParserKind::ContentHeaders (helios/src/model/contract.rs:895-899), so prepare_output() (helios/src/model/prompt.rs:315-328, helios/src/output/pipeline.rs:131-142) has already encoded every marker in helios/src/output/tml.rs:41-44 (CONTROL_MARKERS, including MODEL and TEXT), validated each occupies one token, and stored them in output.control_tokens regardless of whether request tools are empty.
    • tml_text_transition_tokens() re-checks PromptEncoder::TmlV0 + ContentHeaders, hardcodes the marker strings again in request.rs, and reaches into tokenizer().get_added_vocabulary().get_vocab() without prepare_output's single-token guarantee.
    • Fix: Expose a small helper on OutputConfig / helios/src/output/ (reusing tml::MODEL and tml::TEXT against output.control_tokens when ContentHeaders is active) and delete tml_text_transition_tokens() from request.rs.
  3. Supply real-checkpoint / live Inkling 2 verification for the injected <|message_model|><|content_text|> continuation.
    • Every test in this PR scripts the post-cut continuation tokens ([1, 2] in helios/src/server/runtime/phase_tests.rs:760), so nothing yet demonstrates against an actual Inkling 2 checkpoint that injecting <|message_model|><|content_text|> after <|end_message|> keeps the model generating in the text frame rather than immediately closing it or reopening <|content_thinking|>.
    • Fix: Run the real-tokenizer tml_tests.rs suite (and add a thinking_token_budget case there) plus at least one live flare run transcript on an Inkling 2 core demonstrating a hit on thinking_token_budget continuing cleanly into content (both plain and with tools active).

Subtract / Simplify

  1. Collapse ReasoningCut { close, close_tail } into one token sequence and delete the redundant runtime include_tail re-check (helios/src/server/runtime.rs:50-61, 1962-1972, helios/src/server/request.rs:384-400).
    • request.rs:384-393 already checks output.content.tools.is_empty() && grammar.is_none() and 1 + tail.len() < after. None of prompt.grammar, cut.after, or cut.close_tail can change between preparation and Worker::publish(), so the include_tail re-derivation and Vec rebuild at runtime.rs:1962-1972 duplicate an already-decided invariant.
    • Replacing close + close_tail with a single non-empty sequence (built once in request.rs when 1 + tail.len() < after as usize) removes ~20 lines of duplicated policy and the repeated u64::from(1 + ... as u32) < u64::from(after) casts. (phase_tests.rs:786-800 Case 2 only tests that duplicated runtime guard; request-level tight-capacity coverage already exists at decode.rs:2161-2171.)

Nits

Dropped on verification

Full report Decision to Test: no (98%): 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: newjordan (FIRST_TIME_CONTRIBUTOR — first contribution in the repo; no prior PRs or issues in 180 days; Discord frosty40) Motivation: The hard reasoning-token budget added in #167 can be set per request and as a server default, but it refuses to work on Inkling 2 models whose output starts in a TML "content-header" frame — those requests get HTTP 400 and the server default fails startup. This PR lets the budget work there and also repairs a partial multi-byte character left at the cut boundary so the continuation prompt is not corrupt. Scale: +614 / −50 lines in 9 files Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #615 (helios: support thinking_token_budget for ContentHeaders)

What it is. At head 7dde009, #615 enables per-request and [server] thinking_token_budget on TMLv0 ContentHeaders cores (which currently return HTTP 400), plus a byte-exact UTF-8 tail trim on forced reasoning cuts. It is 9 files, roughly +614/−50, with ~+170/−50 in five production files.

Charter alignment — mostly good. The core change is squarely in scope: the charter requires that a standard request field be either implemented per spec or rejected, never quietly dropped, and it requires Chat/Responses/Messages parity. The dossier confirms the earlier architecture objection is genuinely repaired, not papered over: the <|message_model|>/<|content_text|> literals now live once in helios/src/output/tml.rs:25,29, resolved via tml::text_frame_opener() and OutputConfig::reasoning_close_tail() (pipeline.rs:26-41), and request preparation request.rs:380-397 is format-agnostic — so the runtime stays model-agnostic rather than accumulating per-model branches. Two parts drift from the charter. The trim fires on every forced cut in every format rather than the one format the PR is about, and it repairs the prompt while silently dropping text already streamed to the client (open question 1; docs/api.md:817-820 documents only the prompt side). And config.rs:281 now calls prepare_token_bytes() unconditionally for every core — a boot-latency/memory cost for all deployments that appears nowhere in the description's change list and carries no measurement.

Novelty — additive, neither obsolete nor superseded. #167 (merged) is the origin and this edits its own docs/api.md paragraph rather than reversing it. Open #457 (TMLv0 grammar/EOS-on-header shape) and open #582 (scheduler zero_budget_anchor) touch different files; the bot's duplicate check found no file or behavioural conflict. This is genuinely new capability. Caveats: neither PR cross-references the other, and #615 introduces a shrink of up to 3 tokens on the same park() re-admit path that #582's latch assumes (open question 5).

Value vs cost. Real beneficiaries: anyone serving Inkling-2 ContentHeaders cores through OpenAI/Anthropic SDK clients, who today gets an HTTP 400 on a documented API field. Evidence is decent but unaudited: 1,685 + 62 + 242 CPU tests passing, a real-Inkling-2 tokenizer #[ignore] test (tml_tests.rs:355-417) asserting the exact cut sequence, and seven self-reported live GB10/SM121 scenarios including tools, json_object, Messages, and the server-level default. Against that: no CI checks exist on 7dde009, the live transcript is not reproducible from the repo, Inkling-2-Small/vision/TP>1 are untested, there is zero human review (one bot review plus an author reply 25 minutes later), and an undeclared accounting change — up to 3 injected tokens where #167 counted 1 (metrics.rs:333-347).

Verdict: Worth it with changes. The PR fixes a genuine, charter-mandated functional gap and now places the format knowledge in the right layer, so the maintenance cost is defensible. Before merge: (1) CI green on head; (2) declare and either justify or measure the unconditional prepare_token_bytes() startup cost; (3) narrow the trim scope or explicitly address the client-visible/prompt divergence and the identical, untouched dangling-byte hazard in preemption; (4) reconcile with #457 and #582, and confirm #582's anchor latch tolerates a shorter re-admitted prompt; (5) update the stale docs (docs/logprobs-design.md:19, the output_event_capacity comment at runtime.rs:68-70, docs/cli-design.md) and state the generated_tokens change.

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, performance, enhancement, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +performance

Subtraction and simplicity

Subtraction/Simplicity/Conventions lens, PR #615 @ 7dde009. The production diff (5 files, ~+170/−50) is lean: no dead knob, no new flag, no duplicated marker table; the literals live once beside CONTROL_MARKERS (helios/src/output/tml.rs:25,29,41-44) and the earlier tml_text_transition_tokens()/PromptEncoder-keyed branch is correctly gone. Five suggestions, highest value first:

  1. Delete frontend.prepare_token_bytes()? (helios/src/server/config.rs:281). Its only consumer is already a lazy OnceLock (helios/src/frontend/mod.rs:1534-1537); the unconditional call builds one Vec per vocab entry per core at boot (helios/src/frontend/vocabulary.rs:31-39) for cores that never arm a cut — an undeclared resource change (AGENTS.md:88-94).
  2. The new decode test rebuilds the module's own renderer() helper (helios/src/server/protocol/decode.rs:2033-2092 vs renderer at :1035); a third copy is tml_tests.rs:32-91, a fourth is config.rs:663-694 (32 lines to assert one Option). Parametrize renderer with an added: &[&str] and keep only the assertions tml_tests.rs:355-416 lacks: the tight-capacity ladder (decode.rs:2146-2155), tool_choice=none (:2166-2173), Messages budget (:2186-2193).
  3. Option<[u32;2]> → to_vec() → !is_empty() → extend is four spellings of two u32s across tml.rs:47-57, pipeline.rs:29-40, request.rs:384-390, with the capacity rule split across two files; collapse into one OutputConfig::reasoning_close(close, after, grammar) -> Vec.
  4. runtime.rs:433-435's let Ok(bytes) = ... else { return; } is a silent no-op fallback AGENTS.md:182-186 rejects; the 17-line scan at :439-455 re-walks token_spans.rs:129-142 and reduces to ~6 lines using one from_utf8 + valid_up_to().
  5. Keep one of the two guards for "a grammar never sees a tail": drop request.rs:385's grammar.is_none() in favour of the runtime check at runtime.rs:1995-1998.

Checked clean: docs/api.md:817-832, ReasoningCut collapse, phase_tests Vec updates. Open: is prepare_token_bytes measured? which bot "subtract" item was addressed? should the trim be scoped to one format when preemption (:2152) has the same hazard untrimmed?

Full report · Notes

Correctness and contracts

PR #615 at head 7dde009 is architecturally sound in its core but has one Major correctness/documentation gap and three Minor accounting/scope issues.

Major: trim_incomplete_utf8_tail runs in Worker::park() (helios/src/server/runtime.rs:2156-2163), which is only reached after every generated token was already emitted to the client (runtime.rs:1902, emit_output at runtime.rs:490-524) and pushed through the worker-side parser. The trim therefore repairs only the re-prefilled prompt; the streamed text can still end in a stray U+FFFD from the dangling byte token, and docs/api.md:817-820 documents only the prompt side.

Minor, three: (1) the trim is gated on !appended.is_empty() (runtime.rs:2160), so it silently applies to every reasoning format's forced cut, while preemption (park_if_preempted, park(slot, &[], remaining) at runtime.rs:2152) has the identical hazard and is never trimmed; (2) a three-token close now runs emit_output/token-stop matching per token via close_reasoning (runtime.rs:474-488), so a user token stop can truncate the frame mid-header (runtime.rs:2009-2012), and metrics.progress(0, injected.len(), ...) (runtime.rs:2030) adds up to 3 to generated_tokens per single reasoning_budget_cuts increment — unreconcilable for #541 consumers; (3) Bootstrap::load() now calls prepare_token_bytes()? unconditionally (helios/src/server/config.rs:281), building one decoded Vec<u8> per vocabulary entry for every core (frontend/vocabulary.rs:31-39), an unmeasured boot latency/memory change absent from the PR description.

Verified sound: marker ids come only from validated single-token control markers, grammar/tools are guarded twice correctly, required budgets still 400 rather than being silently dropped, the UTF-8 algorithm itself handles literal U+FFFD correctly, no new concurrency surface, and the synthetic plus worker-loop tests are substantive.

Evidence: no CI on 7dde009; the real-tokenizer test is #[ignore]d; live GB10 runs are author-reported. Open questions: client-visible trim semantics, preemption scope, #582's shrinking-prompt anchor latch, and #457's header/EOS interaction.

Full report · Notes

Final review

Recommendation: Ready To Merge

All Round 1 review findings (exact UTF-8 boundary checking, removing the PromptEncoder::TmlV0 branch/hardcoded markers from request.rs, collapsing ReasoningCut to a single close: Vec<u32>, real Inkling-2 tokenizer and live SM121 serving verification, and all three nits) are verified cleanly resolved at head 7dde009. No blockers or regressions were introduced: capacity arithmetic, grammar/tool gating, prompt metadata/vision invariants, and TmlOutput state transitions all hold under direct inspection. Wait for CI to run green on 7dde009 before merging.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

None.

Nits

  1. helios/src/server/runtime.rs:433-435 (trim_incomplete_utf8_tail): let Ok(bytes) = frontend.token_bytes(token) else { return; }; silently skips trimming on error even though park() already returns Result<()> (runtime.rs:2156) and Bootstrap::load() validates prepare_token_bytes()? (config.rs:281). Propagating ? would avoid a silent no-op fallback if an unexpected lookup failure ever occurred.
  2. helios/src/server/protocol/decode.rs:2033-2110: The new test repeats ~77 lines of ByteLevel BPE tokenizer + temp-file + GrammarCompiler setup already implemented in renderer() (decode.rs:1035-1154) in the same test module; parametrizing renderer() (or extracting a shared helper) would reduce test boilerplate without losing coverage.
  3. helios/src/output/pipeline.rs:29-40: reasoning_close_tail(&self) allocates a Vec<u32> from Option<[u32; 2]>; returning Option<[u32; 2]> directly would avoid the temporary allocation before tokens.extend(...) at helios/src/server/request.rs:386-389.
  4. docs/api.md:817-820: Optional wording note—the doc accurately states that incomplete UTF-8 tail tokens are trimmed from the re-prefilled continuation context, and could optionally mention that client-streamed reasoning text before the cut may still end with a replacement character (U+FFFD) when a cut splits a multi-byte character (matching existing forced-cut behavior on main).

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: yes (87%): 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 #615 helios: support thinking_token_budget for ContentHeaders (head 7dde009)

Bottom line

Run a narrow, ~2-hour, single-core non-regression plan — do not plan a speedup measurement, because there is no speedup claim to measure. PR #615 is a correctness/enhancement change (it makes a documented API field work on ContentHeaders cores and repairs a cut-boundary UTF-8 prompt). Triage applied performance at 65 %, but nothing in the PR claims a latency or throughput win, and at head 7dde009 the UTF-8 trim is O(1) (Frontend::token_bytes() lookups over ≤8 tokens, helios/src/server/runtime.rs:417-461, 2160-2162) with no decode() calls left — it is too small to measure against GPU noise. The only performance-shaped thing to check is a startup regression, not a speedup.

And one hard limit on scope: neither machine has an Inkling 2 checkpoint, so the headline behaviour of this PR cannot be exercised on our hardware. ContentHeaders (ReasoningParserKind::ContentHeaders, helios/src/model/contract.rs:68, 907) exists only for Inkling 2 Mini/Small (docs/model-preparation.md:324). cn5/cn7 carry GLM-5.3 and Qwen3.8, whose contracts are ThinkTags (helios/tests/support/contracts/glm53.json:24-30, qwen38.json:29-37) — they take the pre-existing OutputStart::Reasoning budget path (helios/src/server/request.rs:549-551). The <|message_model|><|content_text|> injection and the 1→3 injected-token accounting are unreachable there.

That splits the work cleanly:

If Stage 0 passes and Stage 1/2 show byte-identical behaviour, GPU evidence is complete for what is testable. If Stage 1 diverges, stop and report — the PR touches helios/src/server/runtime.rs, one of the most contended files in the repo, and has zero CI checks on 7dde009.


Stage 0 — CPU only, no GPU time, ~25 min (do this first; it is the highest-value check)

On cn5 (48 CPUs; cn7's 10 CPUs also suffice). Build once, then run tests.

git fetch origin pull/615/head:pr615 && git checkout pr615      # expect 7dde009
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
python -m pip install -r tests/frontend/requirements.txt 2>/dev/null || python -m pip install huggingface-hub
python tests/frontend/prepare_templates.py (not opened) --output /tmp/flare-test-templates \
  --recipe gemma4 --recipe glm53 --recipe mimo_v2 --recipe minimax_m3 --recipe nemotron_h --recipe qwen38 --recipe step5
export FLARE_TEST_TEMPLATE_DIR=/tmp/flare-test-templates
cargo test --locked --release --manifest-path helios/Cargo.toml \
  --target-dir flare-cli/target --features runtime-core,server   # the CI command, .github/workflows/native-serving.yml:63 (not opened)

0b — the one check that closes the real evidence gap (real Inkling 2 tokenizer, still CPU-only):

huggingface-cli download thinkingmachines/Inkling-2-Small \
  --revision b0e7afb8892a07897c78ce1c5b801a0d9cbd5e7b tokenizer.json (not opened) \
  --local-dir /tmp/inkling2-snapshot
FLARE_INKLING2_TEST_SNAPSHOT=/tmp/inkling2-snapshot \
  cargo test --locked --release --manifest-path helios/Cargo.toml \
  --target-dir flare-cli/target --features runtime-core,server -- --ignored tml_tests

Assertions that matter: thinking_budget_prepares_content_headers_cut (helios/src/server/request/tml_tests.rs:355-416) must produce cut.close == [200010, <|message_model|>, <|content_text|>], max_new_tokens == 16, after == 48; tools-active and json_object cases must give cut.close == [200010] only; the omitted-budget case must leave reasoning_cut == None. The five pre-existing tml_tests must also pass (they pin the <|end_message|> == 200010 assumption at tml_tests.rs:25 and the whole renderer parity).

Do not proceed to GPU stages until 0a and 0b are green. If 0b cannot be fetched, say so in the report: the ContentHeaders path then has no real-tokenizer evidence at all and that (not GPU time) is the merge blocker.


Stage 1 — Determinism A/B on GB10 / SM121 (cn7): 1 GPU, ~45 min

cn7 is the right first machine: GB10/SM121 is exactly the class the author reported live evidence on, it is one GPU away from idle, and a TP1 core is far cheaper than a TP4 export.

1.1 Reuse, don't build. No exported core is recorded for these checkpoints, so first check:

./flare-cli/target/release/flare models list --json

1.2 Boot the baseline and the candidate with one fixed request matrix. Same core, same GPU, --max-concurrency 1 (removes batching nondeterminism), only the binary changes.

# baseline
git checkout main && cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
./flare-cli/target/release/flare run CORE --gpus 0 --max-concurrency 1 --host 127.0.0.1 --port 8101
# candidate
git checkout pr615 && cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
./flare-cli/target/release/flare run CORE --gpus 0 --max-concurrency 1 --host 127.0.0.1 --port 8102

1.3 Request matrix — for each of seed in {7, 11} (seed is request-controlled, docs/api.md:44; note temperature 0 is not available — ranges are clamped, docs/api.md:775-795), fire each case against 8101 then 8102, saving the full JSON body:

# Case Purpose
A {"model":"m","messages":[{"role":"user","content":"Explain why quicksort terminates."}],"max_tokens":512,"seed":7} uncapped control — must be identical (proves no no-op drift)
B same + "thinking_token_budget":64 cut fires; assert reasoning_budget_cuts_total == 1 after
C same + "thinking_token_budget":8 tight budget → injected vs after arithmetic near the boundary
D same + "thinking_token_budget":64 + "stop_token_ids":[[<the close token id>]] user stop vs injected token; must terminate cleanly, not corrupt usage
E same + "thinking_token_budget":64 + "tools":[...] + tool_choice default tools path; cut.close stays 1 token either way, tool call must still parse
F same + "thinking_token_budget":64 + "response_format":{"type":"json_object"} grammar active (grammar.is_none() false → no tail, single-token close enforced at runtime.rs:1995-1998); JSON must be valid
G POST /v1/messages with "thinking":{"type":"enabled","budget_tokens":64} Anthropic parity (docs/api.md:845-848)
H POST /v1/responses + "thinking_token_budget":64, "stream":true Responses/streaming parity
I 32 variants of B with thinking_token_budget 1..32, prompt asking for long non-ASCII reasoning (CJK + math symbols + emoji) the only way to reach the UTF-8 trim on this tokenizer — a cut splits a multi-byte char only if the tokenizer splits characters

1.4 Assertions.

  1. Cases A–H: response bodies byte-identical between ports (modulo created/id), and /metrics deltas identical. This is the strong result — for ThinkTags, OutputConfig::reasoning_close_tail() returns empty (helios/src/output/pipeline.rs:26-41), so cut.close == [close] and the PR is intended to be a strict no-op.
  2. Where a cut fires (reasoning_budget_cuts_total incremented, flare_reasoning_budget_cuts_total in /metrics): reasoning text stops at the cap, completion_tokens == budget + 1 + tokens emitted after the cut, usage.completion_tokens_details.reasoning_tokens <= completion_tokens, and the content after the cut is coherent text (not stray markers, not empty).
  3. Case I differs from baseline in ≥1 instance ⇒ the trim path is exercised. For each divergence confirm the candidate's continuation remains coherent and that the streamed reasoning ends with U+FFFD in both binaries (documented behaviour, docs/api.md:817-820; the PR repairs the prompt, not the client stream). Zero divergences across 32 budgets ⇒ report "trim not exercised on this tokenizer" and do not spend more GPU time chasing it — the deterministic coverage is the synthetic byte-level matrix at helios/src/server/runtime/phase_tests.rs:805-869 (including generated_len == 1, 2 and a literal U+FFFD), plus a code ask for a real-tokenizer variant.
  4. Any cut that does not fire is a void test, not a pass. Preconditions are budget present, single-token close delimiter, budget < max_new_tokens, output starting in reasoning, reasoning still open at the cap (helios/src/server/request.rs:368-400, runtime.rs:1992-2005). Check reasoning_budget_cuts_total after every case before believing the result.

Stage 2 — Preemption must stay untrimmed (cn7): ~20 min, same core, no new export

The trim is gated on !appended.is_empty(), so claiming preemption (park_if_preempted → park(slot, &[], remaining), helios/src/server/runtime.rs:2152) must be byte-for-byte untouched. This is the one place a wrong gate would corrupt client output (re-emitting a character), so it is worth 20 minutes.

  1. Restart the candidate with a deliberately small cache: --kv-cache-limit context or --memory-limit <tight> (docs/model-preparation.md:397-406).
  2. Fire two concurrent requests (concurrency forced to 2 via --max-concurrency 2), each max_tokens 512 + thinking_token_budget 64, one of them in non-ASCII text, so live.preempted() and phase == Finishing are reachable (runtime.rs:2133-2145).
  3. Assert: flare_checkpoint_skips_total / preempt-related counters move (proof preemption happened at all), both requests complete with failed == 0, streamed text has no duplicated character at the park boundary, and the completion bodies match the same requests run at concurrency 1 (aside from usage identical, text equal). Repeat once with the baseline binary; results must match.

Stage 3 — Startup regression of the unconditional prepare_token_bytes() (cn7 + cn5): ~15 min, no export needed

helios/src/server/config.rs:281 now calls frontend.prepare_token_bytes()? for every core instead of only when max_top_logprobs != 0. This is the only performance-shaped change, and it is host-side (VocabularyBytes is host RAM, one Vec<u8> per vocabulary entry, helios/src/frontend/vocabulary.rs:14-39) — it must show zero VRAM change. The final review argues every exported core already had max_top_logprobs == 20, so the expected delta is zero; measure rather than assume, but do not build a benchmark around it.

For each binary, 3 boots of the same core:

Pass: boot time and VRAM within noise of baseline; host RSS delta (predict: single-digit MiB for a 154 880-entry GLM vocab). Anything above ~50 MiB or >1 s of added boot time → report as an undeclared startup regression, which is what reviewers flagged as unmeasured.


Stage 4 — Optional, cn5 only, and only if Stage 1 left a real question: TP4 served-workload spot check, ~60–90 min

GLM-5.3-Flash NVFP4 TP4 fits cn5's exactly 4 × 96 GiB (docs/prefix-cache-offload.md:1429 (not opened), docs/roce-ring.md:349 (not opened) qualify TP4 but on four Sparks — this would be a new topology, so treat it as a smoke test only). Use it only for: serve, run cases B/F/E at concurrency 4, and confirm reasoning_budget_cuts_total equals the number of budgeted requests and failed == 0. Do not attempt to measure throughput: charter requires flare run CORE --embedding-table-storage ram with matched configuration for any performance claim (docs/performance-work.md:45-51), which is out of scope here. Skip cn5 entirely if Stage 1 and 2 pass — that is the main GPU-time saving in this plan.

Also skip, deliberately: the facebook/dinov2-base / timm/vit_base_patch14_dinov2 vision models (PR touches no vision path; the prompt-metadata extend_text invariant it relies on is unchanged), tensor-parallel > 1 as a correctness target for this PR, and any multi-host/Orbit work.


Server-level default check (2 min, fold into Stage 1)

Write ~/.config/flare/config.toml (not opened) with [server] thinking_token_budget = 32, boot the candidate on the GLM or Qwen core, then assert: server starts (this is the bootstrap validation the PR widened, helios/src/server/config.rs:416-418), GET /v1/models shows flare.thinking_token_budget == 32 (docs/api.md:842-843), a request that omits the field gets capped (reasoning_budget_cuts_total increments), and an explicit thinking_token_budget overrides it. This is the only "startup accepts the default on a real core" evidence obtainable without Inkling 2.


GPU-time budget

Stage Machine GPU time Blocking?
0 — CPU tests + real Inkling-2 tokenizer cn5 or cn7 CPU 0 yes, prerequisite
1 — determinism A/B + trim sweep cn7 (1 GPU) ~45 min (+0–3 h if an export is needed) yes
2 — preemption untrimmed cn7 (1 GPU) ~20 min yes
3 — boot/RSS/VRAM cn7, optionally cn5 ~15 min no
4 — TP4 spot check, optional cn5 (4 GPUs) 0–90 min no

Single-GPU cn7 does everything essential; cn5 is contingency only. That is the whole point of the plan: this PR has no speedup to demonstrate and its headline path is untestable here.

Stop / report conditions

  1. Stage 0 red → stop; report failing test names. Do not spend GPU time.
  2. Stage 1 case A (uncapped control) differs between binaries → hard stop: the change is not format-isolated; report the diff with seed and body.
  3. Stage 1 case F produces invalid JSON or a failed count → hard stop: grammar/close interaction is broken (the single-token close requirement at runtime.rs:1995-1998 would be the suspect).
  4. Stage 2 shows duplicated/missing characters at a park boundary, or preemption counters stay at 0 while only one request is admitted → hard stop.
  5. Export for Stage 1 exceeds ~3 h → stop, report blocked on export cost; recommend merging on CPU evidence plus maintainer sign-off, since no machine can validate the actual feature.

Residual risk the plan cannot retire (state this in the sign-off)

Real Inkling 2 continuation after <|end_message|><|message_model|><|content_text|> — i.e. whether a real ContentHeaders model keeps generating in a text frame rather than reopening <|content_thinking|> — remains unverified on our hardware, and no GPU on cn5/cn7 can change that. The cheapest way to retire it is the Stage 0b real-tokenizer suite (proves the right token ids for the right markers) plus one author-supplied flare run transcript on an Inkling 2 Mini core; the expensive-but-definitive option is provisioning an Inkling-2-Small core, which is out of this plan's scope.

Content-safety note

No prompt-injection or instruction-override attempts were found in the PR description, dossier, or comments; nothing in the reviewed material was treated as instructions. One oddity worth flagging as data cleanliness only: the second dossier pass carries a garbled phrase ("helios/src/output/{syntax honestly pipeline,tml}.rs") — noise in the case file, not a security issue.

Full report · Notes

Discord Test Request

Discord post (ready to paste)

## Recommendation: Test
High confidence (~80%). Narrow, CPU-first, non-regression plan — not a speedup benchmark.

## Hardware Required
- **CPU only** (cn5 or cn7): `cargo test` suite + the real Inkling-2 tokenizer check — costs 0 GPU minutes, run it first.
- **1 GPU on cn7** (GB10/SM121): baseline-vs-branch A/B on one existing TP1 core (GLM-5.3-Flash or Qwen3.8-27B).
- Only if no core exists: 1× TP1 export on `main` (1–3 h). cn5's 4 GPUs are contingency only.

## Justification
- It's a real fix, not a perf win: `thinking_token_budget` currently 400s on Inkling-2/TMLv0 (`ContentHeaders`) cores, and forced cuts can leave broken UTF-8 in the continuation prompt. Zero CI checks ran on this head, and the author's live evidence can't be reproduced here — we have no Inkling 2 checkpoint, so GPU time can only prove the shared path didn't regress.
- The `performance` label is a misnomer: no latency/throughput claim exists. The only measurable risk is startup — `prepare_token_bytes()` now runs on every boot instead of only for `max_top_logprobs != 0` (expect ~0 VRAM, single-digit MiB RSS).

## Estimated Time to Complete
~2 hours total: 25 min CPU (tests + real tokenizer), ~65 min on 1 cn7 GPU (determinism A/B, UTF-8 trim sweep, preemption check), ~15 min boot/RSS/VRAM. Add 0–3 h only if a core has to be exported first.

How I checked it (verification of the plan's claims against the repo at PR head 7dde009)

Caveats I could not retire

Full report