#1 [high] Change: what PR #615 does, file by file (size +562/−31, 6 files)
PR #615, head 2652c06, base main, +562/−31 across 6 files. Branch feat/helios-tml-thinking-budget. Author newjordan (FIRST_TIME_CONTRIBUTOR), opened/updated 2026-11-29 19:04, no reviews, no comments, no CI checks.
Actual diff (verified by reading pr_diff):
- helios/src/server/request.rs (+32/−3):
prepare_validated_inference: when budget < max_new_tokens, buildsclose_tail=tml_text_transition_tokens(frontend, config)ifoutput.content.tools.is_empty() && grammar.is_none()and1 + tail.len() < after; else empty. Sets max_new_tokens = budget; ReasoningCut { close, close_tail, after, output }.- New
fn tml_text_transition_tokens(frontend, config) -> Vec<u32>: requiresfrontend.prompt_encoder() == PromptEncoder::TmlV0andconfig.contract.frontend.reasoning.kind == ReasoningParserKind::ContentHeaders; then looks up added-vocabulary ids for "<|message_model|>" and "<|content_text|>", returns vec![model, text] or empty. thinking_budget_close: wasif !matches!(start, Reasoning | Content) { return Ok(None) }; nowsupported_start = matches!(Reasoning|Content) || ((RecipientFrame|RecipientHeader) && syntax.kind == ContentHeaders). Note theconfig.contract.frontend.reasoninglookup moved before the start check (soNonereasoning syntax still returns Ok(None) for any start).- Note:
RecipientHeadersis explicitly NOT widened (only ContentHeaders) — description says "RecipientHeaders behavior unchanged".
- helios/src/server/runtime.rs (+76/−22):
ReasoningCutgainspub close_tail: Vec<u32>field (with doc comment).Worker::publish()budget branch: buildssequence= [close] + close_tail if!cut.close_tail.is_empty() && request.incoming.prompt.grammar.is_none() && 1 + close_tail.len() < cut.after; callsrequest.close_reasoning(token, eos)per token, collectinginjected; breaks onstopped(sets budget_stop), abandons on error. Records each injected token viascheduler.record_decoded_token, incrementsreasoning_budget_cutsonce,metrics.progress(0, injected.len(), ...).remaining = cut.after.saturating_sub(injected.len() as u32)(wascut.after - u32::from(forced)).appended=&injectedwhen forced (wasslice::from_ref(&cut.close)).Worker::park(): new UTF-8 trimming block beforetokens.extend_from_slice(appended): applies only if!appended.is_empty()and there are generated tokens; decodes an 8-token windowtokens[len-8..](clamped to live.prompt_tokens); if text ends with U+FFFD, tries trim 1..=min(3, generated_len-1) and truncates at the first trim where the window no longer ends with U+FFFD (andend > window_start). Guarantees at least one generated token remains.- Test updated:
ReasoningCut { close: 8, close_tail: Vec::new(), after: 20, ... }in runtime tests.
- helios/src/server/config.rs (+48/−0): new test block in existing bootstrap test: builds tokenizer with TML special tokens, prompt_encoder=3 (TmlV0?), thinking_token_budget=16, ContentHeaders reasoning with open "<|content_thinking|>" / close "<|end_message|>", TmlJson tools; asserts Bootstrap::load succeeds and
loaded.server.thinking_token_budget == Some(16). - helios/src/server/protocol/decode.rs (+192/−0): one new test
tml_content_headers_thinking_budget_prepares_close_and_optional_text_frame_tailinnative_prompt_tests: builds a byte-level BPE tokenizer with the 14 TML special tokens, loads contract fixtureshelios/tests/support/contracts/inkling2_frontend.json["text"], then asserts: uncapped cases (no budget, reasoning_effort=none, enable_thinking=false) → no cut, max_new_tokens=32; plain Chat budget=16 → close=<|end_message|>, close_tail=[model,text], after=16; budgets 29/30/31 (after<=3) → close_tail empty; tools present → close_tail empty; tool_choice=none → tail restored; response_format json_object (grammar) → tail empty; Messages thinking.budget_tokens=16 → same cut. - helios/src/server/runtime/phase_tests.rs (+202/−0):
budget_cuthelper gainsclose_tail: Vec::new(); two new tests:reasoning_budget_injects_content_headers_close_tail_and_accounts_for_capacity: 3 cases (capacity 5 → injects [end, model, text], parked prompt tokens [0, model, think, 0, end, model, text], max_new_tokens 2, carried.generated_tokens 6, cuts metric 1, final finish (1,8,"length"), OutputPipeline decodes reasoning_content "a" content "bc"); capacity 3 → [end] only, generated_tokens 4; reasoning already closed → nothing injected, max_new_tokens 5.reasoning_budget_park_trims_incomplete_utf8_tail_without_affecting_plain_continuation: byte-level fixture with bytes 0xE2/0xAC/0xA2 = U+2B22; 1-byte and 2-byte partial tails trimmed from parked prompt, complete char kept; and withappendedempty (unforced continuation via budget_cut? — actually reasoning_cut set but reasoning closed) the partial tail is preserved.
- docs/api.md (+12/−6) in the thinking_token_budget section (~line 814): documents ContentHeaders support, silent <|message_model|><|content_text|> tokens when no tools/grammar, UTF-8 tail trimming, and changed 400-condition wording to "when output starts in reasoning or a content-header frame".
#2 [high] Why: the problem, prior art (#167) and how long it has been wanted
The problem the PR addresses is a gap in an existing, merged feature, not a new feature request.
thinking_token_budget(per-request +[server]default) was added by PR #167 "Add a hard reasoning-token budget and DeepSeek V4.1 sampling ranges" by yatesdr (COLLABORATOR), merged 2026-11-02, +1899/−98, 31 files. Commit 902c88e2. It introducedthinking_budget_close()in helios/src/server/request.rs,ReasoningCut, the park/re-admit cut path in runtime.rs, metricreasoning_budget_cuts_total(helios/src/server/metrics.rs:1090), startup validationServerConfig::validate_thinking_budget(helios/src/server/config.rs:411-438) advertised in/v1/models, and messages-budget wiring.- #167 explicitly designed the reject path: "On formats that cannot honour a hard cap,
thinking_token_budgetis rejected while Messagesthinking.budget_tokenskeeps its documented advisory meaning." Its live evidence was DeepSeek V4.1 Flash TP4 on 4× RTX PRO 6000 SM120 only. It had zero discussion/reviews recorded (Discussion (0)). - Before #615,
thinking_budget_close(helios/src/server/request.rs:557-578 at head) returned Ok(None) unless start was Reasoning|Content, so TMLv0/ContentHeaders cores (which start at OutputStart::RecipientFrame — see helios/src/output/tml.rs:79-93prompt_start) got HTTP 400 "thinking_token_budget is not supported by this model's reasoning format" (request.rs:368-379) and a startup failure for the[server]default (config.rs:416-435). - Length/wantedness: no issue, discussion or PR reports this gap. Searches for "thinking_token_budget" in issues return nothing; search_items for "ContentHeaders reasoning parser kind", "UTF-8 byte token decode incomplete replacement character", "budget_tokens Inkling" all returned no matching issue/PR. So the demand is not independently documented outside the PR description; the only link is #167's design plus #457's TMLv0 work.
- The second half (UTF-8 tail) has no prior report either. It is plausibly a real artifact: the old code appended
cut.closeontolive.tokens()(runtime.rs:2128 old) andprompt_metadata::extend_textonly pads positions (helios/src/model/admission.rs:25-56), so a mid-character byte-level BPE tail stays in the re-prefilled prompt.
#3 [high] Related work: #167 (origin), #457 (TMLv0 ContentHeaders), #582 (touches same park path), #541 (metric consumer)
- #167 (merged 2026-11-02, yatesdr): created the whole feature this PR extends. #615 is additive over it — it does not reverse #167, it widens
thinking_budget_closeand extendsReasoningCut. #167's own docs text (docs/api.md:813-833) is what #615 edits. - #457 (open, brandonmmusic-max, updated 2026-11-29 03:33, labels area:api/bug/model:inkling-small/triage:review, +431/−7): "Fail untyped TML model headers at EOS and align TMLv0 content-header and strict-tool grammars with TmlOutput". It changes the same objects #615 depends on:
helios/src/output/tml.rs(TmlOutput,AnswerState,finish()erroring at EOS for a header without content) andhelios/src/grammar.rs/grammar/strict.rs(compile_content_headers,tool_unnamed, preamble-then-tool ending). Interaction worth flagging: #615 injects<|message_model|><|content_text|>, i.e. an unnamed model header immediately followed by a content-kind marker — exactly the "header without content" shape #457 introduces new EOS error handling for, and exactly the "unnamed header" shape #457's grammar rules change. #615 guardsgrammar.is_none()for the tail, so the grammar side is not hit, but the parser side is not guarded. No cross-reference between #457 and #615 exists in either direction; #457 was last updated the same day #615 opened. - #582 (open, FujitsuPolycom, approved 2026-11-29 by voipmonitor): changes the scheduler/checkpoint side of
Worker::park()readmission; lukealonso's review there citeshelios/src/server/runtime.rs:2106-2121park extendingincoming.prompt.tokens, i.e. the same function #615 edits (lines 2125-2156 at #615's head). Both are in flight and touch the same prompt-rewrite path; #582 also wants a rebase. - #541 (open, jere357, monitoring example) documents
reasoning_budget_cuts_total; #560/#548 (open, WynnD) rework per-request metrics around runtime instants — #615 adds tometrics.progress(0, injected.len(), ...)accounting, so metric-count semantics are shared ground. - Items touching helios/src/server/runtime.rs recently (from items_touching): #615, #554, #483, #560, #576, #540, #548, #549, #334, #301, #607(merged), #497(merged), #505, #579, #102, #504, #507, #479, #416, #459 — a heavily contended file.
- Superseded/undone: none found; no other open PR targets thinking_token_budget or ContentHeaders.
#4 [high] Change: behaviour beyond the description (metric/stop accounting, truncated injection, decode-window heuristics)
Verified from the diff and surrounding code, not stated in the description:
-
A second opaque token is pushed through the output parser and stop matcher.
Active::close_reasoning()(helios/src/server/runtime.rs:431-444) runs grammar.advance +incoming.observe_token+carried.generated_tokens += 1+emit_output. The PR routes everyclose_tailtoken through it, so<|message_model|>and<|content_text|>are counted as generated tokens, pass throughTokenStops/text_stopsmatching, and can setbudget_stopif a user token-stop sequence ends with them. The docs say only "Forced close tokens count as generated tokens within the output limit" — which now means 1 or 3 tokens, not one.docs/logprobs-design.md:19still says "Forced tokens, such as thethinking_token_budgetclose, have no logprob entry", unchanged by this PR. -
The close token is no longer necessarily the only recorded token.
scheduler.record_decoded_tokenis now called once per injected token (runtime.rs:1991-1995), soinjected.len()tokens enter the decoded-history/copy-proposal index rather than one. -
injectedis truncated whenstoppedis true. The loop breaks onstopped, pushing the token intoinjectedbut skipping the rest of the tail;budget_stop = truethen ends the request, soclose_tailmay never be emitted even when capacity allowed it — an unmentioned partial-injection path (contrast the "all-or-nothing" wording in the description, which refers only to the grammar/capacity guards). -
UTF-8 trimming depends on a decode of the last 8 tokens returning trailing U+FFFD. The window is
tokens[len-8..]clamped tolive.prompt_tokens; the check isdecode(...).is_ok_and(|t| t.ends_with('\u{FFFD}')). Trimming loop requiresend > window_start. If the model emitted more than 8 tokens of nothing but an incomplete character, or the decoder does not surface U+FFFD (incremental vs. batch decode behaviour differs), no trim happens. It also only trims whenappendedis non-empty — i.e. only on a forced cut, not on preemption (park_if_preemptedpasses&[], runtime.rs:2121) nor on unforced continuation. -
A silent data-loss path the description does not mention: trimming drops up to 3 already-generated tokens from the continuation's prompt. Those tokens were already emitted to the client as text in the first pass (they went through the Decoder/stops), so they are not duplicated, but the model's re-prefilled context no longer matches what the client saw.
carried.generated_tokens(prompt accounting) still countslive.generated_tokens(runtime.rs:2158-2162), unaffected by the trim. -
No test asserts the trimming case where trimming is impossible. The tests cover 1-byte, 2-byte, complete character, and
appendedempty — not "window_start boundary reached" (theend > window_startguard) nor "more than 3 trailing partial tokens". -
The
close_tailguard duplicates in three places with the same predicate1 + tail.len() < afterbut different types: request.rs:386 (u64::from(1 + tail.len() as u32) < u64::from(after)), runtime.rs:1962-1965 (u64::from(1 + cut.close_tail.len() as u32) < u64::from(cut.after)). Both are strict<, i.e. after must be at least 4 for the 2-token tail. Startup validation (validate_thinking_budget) uses the samethinking_budget_close, so the[server]default is now accepted at bootstrap for ContentHeaders — that is the config.rs test. -
thinking_budget_closereordering: theSome(syntax) = &config.contract.frontend.reasoninglookup now runs before the start match, so forOutputStart::Reasoning|Contentcores with no reasoning syntax the result is the same (Ok(None)), but the function no longer short-circuits on start alone. No behaviour change found, but it is a restructuring, not a pure widening. -
Not implemented although related:
RecipientHeaders(kind 5) stays unsupported for frame starts;OutputStart::ToolBodystays unsupported. The description saysRecipientHeadersbehaviour is unchanged, which matches. -
The
config.rstest is written against a fabricated tokenizer plus a hand-written contract, not a real Inkling 2 checkpoint; the decode.rs test loadshelios/tests/support/contracts/inkling2_frontend.json(verified: text.reasoning = {kind 6 ContentHeaders, open<|content_thinking|>, close<|end_message|>}, assistant_marker<|message_model|>, tools kind 8) into a synthetic byte-level BPE tokenizer.
#6 [high] Project fit: charter alignment on API completeness vs the model-agnostic/evidence rules
Charter points (read via read_charter):
Where it lines up
- "Support the documented Chat Completions, Completions, Responses, and Messages APIs (including token counting)" and "We target ... the Anthropic Messages API": the PR makes
thinking_token_budgetand Messagesthinking.budget_tokenswork instead of returning HTTP 400 on TMLv0 cores, and updates docs/api.md:813-833/844-850 accordingly. - "Don't silently ignore API fields ... either implement it according to the spec or reject it (#417)": before, the field was rejected for ContentHeaders; now it is implemented for that format. Consistent.
- "PR descriptions: Expect four parts — why, what changed, claimed result, evidence": the description has all four plus a limitations section.
- "Keep the runtime small and model-agnostic ... shouldn't accumulate per-model branches (#267, #334)" and "No per-model special cases or flags": this is the tension. The new code is keyed on
PromptEncoder::TmlV0+ReasoningParserKind::ContentHeaders(request.rs:543-555) and hardcodes two literal token strings<|message_model|>and<|content_text|>(request.rs:551), the same literalshelios/src/output/tml.rs:25-38already hardcodes asCONTROL_MARKERS. So it follows an existing pattern rather than inventing a new branch, but it is a format-specific special case in the request-preparation layer, and it lives in helios rather than in the contract/parser that already knows the marker list. The contract hasreasoning.open/closebut no declared text-opener; the PR does not add one. - "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)": the UTF-8 fix is a heuristic applied at one call site (park), not a general fix in the decoder/history; the same dangling-byte condition outside a forced cut (preemption, output limit) is untouched. Arguably a partial root-cause fix.
- "Bring real evidence. Performance PRs need benchmarks ... Bug fixes need ... (#210)": the evidence is CPU test suites only. No live
flare runon an Inkling 2 core, no before/after on a real checkpoint — the exact#[ignore]real-snapshot tests (tml_tests.rs, needingFLARE_INKLING2_TEST_SNAPSHOT) were not run, and live GPU serving was not re-run. Compare #457 and #582, which both supply live SM120 evidence. - "Supported matrix & compatibility: Check interactions across every supported model, cache scheme, parallel layout..." — the change touches a shared path (
park), so the compatibility surface is all reasoning formats + preemption + speculative completion; the tests cover forced-cut/preemption-empty/unforced paths only for the new tail, and one existing test was mechanically updated for the newclose_tailfield. - Non-goals: nothing violated (no new model, hardware, or backend).
- "Respect contributors / priority contributors": newjordan is not a priority contributor; charter says every PR judged on merits and, if something is missing, the review spells out what's needed.
- docs/TODO.txt:5 still lists "[ ] Qualify
strict: truefunction tools on a TMLv0 core" — TMLv0 is still not fully qualified, and this PR does not touch that; related to #457's scope. - docs/TODO.txt:176-179 asks whether default request parameters get a config mechanism "beyond [server] thinking_token_budget" — the PR extends that setting's reach, consistent with the open TODO rather than resolving it.
#7 [high] Claims and evidence: what is backed by the diff, what is only self-reported, what is unrun
Claims vs what backs them (all quoted from the PR description unless noted).
Backed by the diff/tests (verified by reading them)
- "thinking_budget_close() accepts OutputStart::RecipientFrame and OutputStart::RecipientHeader when ReasoningParserKind::ContentHeaders is configured with a single-token close delimiter": request.rs:567-577. Single-token requirement is the
[close] => Some(*close)match at 574-577. Verified. - "Adds tml_text_transition_tokens(), which resolves <|message_model|> and <|content_text|> from the tokenizer's added vocabulary": request.rs:543-555, via
get_added_vocabulary().get_vocab(). Verified. - "guards: PromptEncoder::TmlV0 + ContentHeaders, no tools (
output.content.tools.is_empty()), no grammar,1 + close_tail.len() < after": request.rs:384-393. Verified. (Notetool_choice=nonemakesoutput.content.toolsempty — the decode.rs test asserts the tail comes back.) - "Worker::publish() emits cut.close followed by cut.close_tail ... records every injected token ... subtracts injected.len() from cut.after (preserving output_event_capacity() and total generated_tokens)": runtime.rs:1959-2017. Note
Prompt::output_event_capacity(runtime.rs:68-88) still addsmax_new_tokens + cut.afterand its comment still says "A reasoning cut's forced token is part ofafter" (line 70) — the invariant holds becauseafteris reduced by injected.len(), so capacity is unchanged, but the comment is now slightly stale for the 3-token case. - "In Worker::park(), ... up to 3 trailing generated tokens are trimmed ... always retaining at least one generated token": runtime.rs:2129-2155, guarded by
generated_len.saturating_sub(1)andend > window_start. Verified. - "Preemption (appended empty) and unforced continuations are untouched": runtime.rs:2121 passes
&[]; runtime.rs:2013 passes&[]when !forced. Verified. - Tests exist for: bootstrap validation of
[server] thinking_token_budgeton TmlV0/ContentHeaders (config.rs, new block at ~line 663-708); request preparation across plain/tight-capacity(29,30,31)/tools/tool_choice=none/grammar/Messages budget_tokens/uncapped (decode.rs:2031-2223); worker close_tail injection + capacity accounting + OutputPipeline decode (phase_tests.rs:680-820); 1-byte/2-byte/complete UTF-8 tail plus plain continuation (phase_tests.rs:825-880).
Test numbers (as claimed, not reproducible here)
- "1,685 passed, 0 failed, 45 ignored" for
--features runtime-core,server -- --skip engram::, plus "62 passed" integration binaries, "39 passed, 2 failed" for engram:: (attributed toRLIMIT_MEMLOCK8 MiB / io_uring_register_buffers OOM; engram untouched by the diff — verified: no engram file in pr_files), flare "242 passed, 0 failed, 4 ignored", flare-clicargo checkclean. No CI run exists on the head commit to confirm any of this ("no checks"), and the numbers are self-reported.
Claimed but NOT done / not evidenced
- "Eliminates dangling incomplete UTF-8 byte tokens before forced close tokens across all reasoning formats in Worker::park()": true of the code path (it is format-agnostic inside park, gated only on
!appended.is_empty()), but this only covers the forced-cut case; the same byte-level hazard on preemption (park_if_preempted, runtime.rs:2121) and at the output limit remains. The description also says the trim is what "eliminates" the problem without stating that decoded content already emitted to the client keeps the raw bytes. - "Keeps TMLv0 plain-text continuations directly inside Body::Text via silent control tokens": the mechanism is right, but note it does not hold if the model, after
<|end_message|>, opens its own frame anyway — the parser handles both; the tail only short-circuits the common case. The description's causal claim ("where it can immediately open a second<|content_thinking|>frame") is the motivation, and there is no test that a real Inkling 2 model actually continues in text rather than re-opening thinking after the injected tail. - TLA+ TLC runner not run (no java/tla2tools.jar); justified as no scheduler state machine change — verified: the diff touches no scheduler/*.rs, only runtime.rs accounting calls.
- Real-checkpoint
#[ignore]tests and live GPU serving not re-run: this is the main evidence gap, since the whole point is behaviour on Inkling 2 Mini/Small cores. - No before/after demonstration of the HTTP-400 to working-budget transition against a real core (no curl transcript, no sample stream).
- The claim that
<|end_message|>closes the TMLv0 thinking frame is verified from the contract fixturehelios/tests/support/contracts/inkling2_frontend.json:8-14andhelios/src/model/contract.rs:907(ContentHeaders default open/close).
#8 [high] Reach: who is affected — all reasoning formats get UTF-8 trimming, TMLv0 cores get budgets, operators and metrics consumers
Who/what is affected (verified in code, not claimed).
Users / API surface
- Chat Completions, Responses, Messages clients that send
thinking_token_budgetand Anthropicthinking.budget_tokenson a TMLv0/ContentHeaders core: previously HTTP 400 "thinking_token_budget is not supported by this model's reasoning format" (helios/src/server/request.rs:369, 375-377); now accepted and hard-capped. Only whenbudget.tokens() < max_new_tokens(request.rs:381), unchanged. - Models: only
PromptEncoder::TmlV0+ReasoningParserKind::ContentHeaders— i.e. Inkling 2 family perignition/preparation/frontend.py:108(model_type inkling2 / inkling2_loop) andhelios/tests/support/contracts/inkling2_frontend.json. Also applies to vision ("vision" block has the same kind 6 reasoning in that fixture). - All other reasoning formats now get the UTF-8 trim as well (DeepSeek/XTML/ThinkTags/Recipient/DSML), because the trim is inside
parkgated only on!appended.is_empty()— this is the widest reach in the PR and the description only credits it in a bullet ("across all reasoning formats"). Anythinking_token_budgetuser on any format sees a possible change: up to 3 generated tokens can be dropped from the continuation prompt, and the previously-emitted text is retained on the client side.
Operators / configuration and defaults
[server] thinking_token_budgetnow validates at startup for TMLv0/ContentHeaders cores (helios/src/server/config.rs:411-438 via thinking_budget_close); previously bootstrap failed./v1/modelsadvertises the value (docs/api.md:835-842).- No new config keys, no new CLI flags, no change to defaults: a core with no
[server] thinking_token_budgetbehaves as before. - New metric accounting:
flare_reasoning_budget_cuts_totalstill increments once per cut (runtime.rs:1996-1998), butmetrics.progress(0, injected.len(), ...)now counts 1 or 3 generated tokens (runtime.rs:1999) — dashboards/consumers like #541 will see generated-token totals include the injected tail. - Client-visible finish/usage:
generated_tokensreported to the client still comes fromlive.generated_tokens+ carried, and the injected tokens are included in the output limit, so a cut request'susage.completion_tokenscan now include 3 hidden control tokens where it used to include 1 (docs/api.md:823-824 says "Forced close tokens count as generated tokens within the output limit").
Compatibility / dependencies
- Wire/protobuf/core ABI: untouched (no serialization change to
ReasoningCut, which is an in-process struct in helios/src/server/runtime.rs). Exported cores unaffected; no ignition change. - Grammars: unchanged. When a grammar is active the tail is suppressed both at prepare time (request.rs:384) and at publish time (runtime.rs:1962-1963), so grammar state machines never see the extra tokens.
- Tests/docs touched: helios/src/server/config.rs, protocol/decode.rs, runtime/phase_tests.rs, runtime.rs unit test, docs/api.md. docs/logprobs-design.md:19 not updated (still says "the thinking_token_budget close" singular).
- Related docs that remain silent: docs/cli-design.md:1337/1367/1417 still describe
[server] thinking_token_budgetwithout the TMLv0/ContentHeaders case; docs/TODO.txt:5 TMLv0 qualification still open.
Deployment risk surface
parkis used by preemption, speculative-completion cuts, and budget cuts; the new decode calls (self.frontend.decode(...)up to 4 times) run on the worker thread inside park, one decode per forced cut, so cost is bounded but non-zero on the hot cut path. No benchmark for it.- The forced-cut path now may emit a partially-injected tail and terminate (budget_stop on a user token stop), which is a new terminal shape.
#10 [high] Research summary
I prepared the case file for PR #615 (helios: support thinking_token_budget for ContentHeaders and trim incomplete UTF-8 tails on cut), covering all eight angles with nine scratchpad entries.
What I established. The change is additive over #167 (merged 2026-11-02, yatesdr), which created the whole hard-reasoning-budget feature and deliberately rejected formats that could not honour a cap — TMLv0/ContentHeaders starts at OutputStart::RecipientFrame, which thinking_budget_close() did not accept, so both per-request and [server] thinking_token_budget returned HTTP 400 on Inkling 2 cores. #615 widens that function, adds tml_text_transition_tokens() (literal <|message_model|>/<|content_text|> from the added vocabulary) as ReasoningCut::close_tail, injects it through Active::close_reasoning() in publish(), and adds a U+FFFD-heuristic trim of up to 3 trailing generated tokens inside Worker::park(). Production code is only ~+156/−25; the rest is tests and docs.
Beyond the description (high importance for a reader). Injected tail tokens are routed through the stop/grammar path and counted as generated tokens, record_decoded_token is now called per injected token, injected can be truncated mid-tail when a user token stop matches, and — most importantly — the UTF-8 trim is gated only on !appended.is_empty(), so it silently applies to every reasoning format's forced cuts (up to 3 already-emitted tokens dropped from the continuation prompt), reaches further than "ContentHeaders" implies, and does not cover preemption or the plain output limit.
Related work and tensions. #457 (open, same day, reviewed) rewrites exactly the TMLv0 TmlOutput/"header without content" and unnamed-header grammar semantics that the injected <|message_model|><|content_text|> sequence depends on, with no cross-reference either way; #582 (open, approved) edits the same park prompt-rewrite path and needs a rebase. Charter fit is mixed: it lines up with "implement or reject API fields" and Messages support, but sits against "keep the runtime model-agnostic" (format-keyed branch with hardcoded literals in the request layer) and against the evidence rule (CPU tests only, no live Inkling 2 run, real-checkpoint #[ignore] tests unrun, no CI checks on the head commit).
Process/community. Ready-for-review, unlabelled, untriaged, zero comments, zero reviews, no CI, never updated since opening; author is a first-time contributor with no prior history; area owners are Luke Alonso / Martin Vit / yatesdr, and the budget code is yatesdr's. No issue anywhere reports this gap, so demand is documented only by the code gap itself.
All file:line citations, the claim-by-claim evidence mapping, the reach analysis (users, models, operators, metrics, docs) and the process facts are in the scratchpad entries (1, 4, 7, 8 are high importance).
#12 [high] File map: where every piece of the change lives, with line anchors for reviewers
Changed files (6, +562/−31) and the anchors a reviewer needs:
-
helios/src/server/request.rs (+32/−3)
- 368-407 request preparation: the
reasoning_cutblock; newclose_tailconstruction at 384-393. - 543-555 new
tml_text_transition_tokens()(TmlV0 + ContentHeaders gate; literal "<|message_model|>"/"<|content_text|>" lookup at 550-554). - 557-578
thinking_budget_close()widened:supported_startat 567-569; single-token close requirement at 573-577. NOTE theSome(syntax) = &config.contract.frontend.reasoninglookup moved above the start match (564-566), a restructuring beyond a pure widening. - Unchanged but load-bearing: 369/375-377 the HTTP 400 message; 381
budget < max_new_tokensgate.
- 368-407 request preparation: the
-
helios/src/server/runtime.rs (+76/−22)
- 50-61
ReasoningCut+close_tailfield (doc comment 53-57). - 431-444
Active::close_reasoning()— reused unchanged per injected token. - 1950-2017
Worker::publish()budget branch:include_tailat 1962-1965, sequence build 1966-1972, per-token loop 1973-1989,injectedbookkeeping 1991-1999,remainingat 2011,appendedat 2013. - 2121
park_if_preemptedpassing&[](the path the trim deliberately does not cover). - 2125-2198
park(): new UTF-8 trim block 2129-2155,tokens.extend_from_slice(appended)2156, metadata extend 2167-2168. - 3393-3399 runtime unit test updated for the new field.
- Related unchanged code: 68-88
Prompt::output_event_capacity(comment at 69-70 still says "A reasoning cut's forced token is part ofafter").
- 50-61
-
helios/src/server/config.rs (+48/−0): entirely a new test block inside the existing bootstrap test (~663-708), building a TML tokenizer + ContentHeaders/TmlJson contract,
thinking_token_budget=16, asserting load succeeds. Startup validation itself is unchanged: 400/411-438validate_thinking_budgetcallsthinking_budget_close. -
helios/src/server/protocol/decode.rs (+192/−0): one test,
tml_content_headers_thinking_budget_prepares_close_and_optional_text_frame_tail, innative_prompt_tests(starts ~2031). Builds a synthetic byte-level BPE tokenizer + 14 TML added tokens, loadshelios/tests/support/contracts/inkling2_frontend.json["text"], then asserts uncapped / plain / tight-capacity 29-31 / tools / tool_choice=none / json_object grammar / Messages budget cases. -
helios/src/server/runtime/phase_tests.rs (+202/−0):
budget_cuthelper gainsclose_tail: Vec::new()(~417);reasoning_budget_injects_content_headers_close_tail_and_accounts_for_capacity(~680);reasoning_budget_park_trims_incomplete_utf8_tail_without_affecting_plain_continuation(~825, uses byte-level tokens E2/AC/A2 = U+2B22). -
docs/api.md (+12/−6): the
thinking_token_budgetsection, 813-833 (new 817-825 text) and the 400-condition sentence 830-833.
Supporting unchanged files a reviewer will want: helios/src/output/tml.rs:25-44 (CONTROL_MARKERS literals), 79-93 (prompt_start → RecipientFrame), 150-152 (reasoning_open = Body{Thinking, model:true}), 224-311 (state machine: END between frames closes nothing), 305-309; helios/src/model/contract.rs:68 (kind enum), 891-907 (ContentHeaders defaults), 923; helios/src/model/admission.rs:25-56 (extend_text monotonicity); helios/tests/support/contracts/inkling2_frontend.json:8-14, 21-25; helios/src/server/metrics.rs:1090 (reasoning_budget_cuts_total).
#14 [high] Research summary
Amendments to the #615 case file (report of 2026-11-29, run 2390) after the new event: the branch was force-pushed from 2652c06 to 7dde009 (+614/−50 over 9 files, was +562/−31 over 6), labels area:api/enhancement/triage:review were added, a flare-autobot review was posted (Changes Requested, 19:28), and the author replied with fixes at 19:53. Every number, file list, and line anchor in the earlier case file is now stale; the substantive findings that survive are listed at the end.
1. Scope and map (supersedes entry #1, #12, #9). Nine files now: adds helios/src/output/tml.rs (+13), helios/src/output/pipeline.rs (+17), helios/src/server/request/tml_tests.rs (+63); request.rs shrank to +15/−4, config.rs to +35/−1, decode.rs +165/−1, runtime.rs +90/−30, phase_tests.rs +203/−8, docs/api.md +13/−6. Production code is now ~+170/−50 across five source files plus one real-tokenizer test file. All runtime.rs anchors moved: injection is runtime.rs:1994-2031, park() is 2156-2163, trim helper 417-461, ReasoningCut 50-61.
2. The duplicated/hardcoded TML transition tokens are gone (retires entry #6's charter finding and the "format-keyed branch in the request layer" complaint). tml_text_transition_tokens() no longer exists. OutputConfig::reasoning_close_tail() (helios/src/output/pipeline.rs:26-41) gates on ReasoningParserKind::ContentHeaders + content.tools.is_empty() and calls tml::text_frame_opener() (helios/src/output/tml.rs:46-57), which resolves MODEL/TEXT from the already-validated single-token output.control_tokens (pipeline.rs:22-23, populated from declared_control_tokens at helios/src/model/prompt.rs:213-223 via helios/src/server/config.rs:279-280). The literals now live once, in helios/src/output/tml.rs:25,29 beside CONTROL_MARKERS (tml.rs:41-44). Request prep is format-agnostic: helios/src/server/request.rs:380-397.
3. ReasoningCut is one prepared sequence; the double guard is gone (supersedes entry #4 items 7 and 3's "close + close_tail" accounting). pub close: Vec<u32> (runtime.rs:55); capacity tokens.len() + tail.len() < after as usize is checked once at preparation (request.rs:384-390). The grammar path now requires a single-token close explicitly: cut.close.len() == 1 && grammar.allows(cut.close[0]) (runtime.rs:1995-1998), so a grammar never sees an injected tail. Injected tokens are still emitted through Active::close_reasoning() (runtime.rs:2004-2020), so the earlier findings persist unchanged: each injected token increments carried.generated_tokens, passes grammar advance and token-stop matching, a user token stop still truncates mid-sequence via the budget_stop break (runtime.rs:2009-2012), record_decoded_token runs per token (runtime.rs:2023-2026), and metrics.progress(0, injected.len(), …) (runtime.rs:2030, helios/src/server/metrics.rs:333-347) makes cluster generated_tokens count 3 where #167 counted 1. docs/api.md:823-824 still says only "count as generated tokens" without saying 1 or 3.
4. The UTF-8 repair is now exact, not a U+FFFD heuristic (supersedes entry #4 items 4-6). trim_incomplete_utf8_tail() (runtime.rs:417-461) concatenates Frontend::token_bytes() for the last ≤8 generated tokens, walks std::str::from_utf8() and truncates at the token boundary covering Utf8Error::error_len() == None only — literal U+FFFD and complete characters survive, and the old "keep ≥1 generated token"/generated_len-1 floor is gone, so generated_len == 1/2 now trims. Gated on !appended.is_empty() at the call site (runtime.rs:2160-2162), so the scope finding survives: it fires on every forced reasoning cut in every format, and preemption (park_if_preempted passes &[], runtime.rs:2152) plus the plain output limit are still untrimmed. Dropping up to 3 already-client-visible tokens from the re-prefilled prompt is still silent; no message boundary can be affected because only indices ≥ live.prompt_tokens are touched. docs/api.md:821-823 now states the "all reasoning formats on forced cuts" scope (the earlier doc-scope gap is closed).
5. New boot-time cost, not in the description's before/after bullets. helios/src/server/config.rs:281 drops the model.max_top_logprobs != 0 gate, so frontend.prepare_token_bytes()? now builds VocabularyBytes (helios/src/frontend/vocabulary.rs:11-45, one decoded Vec<u8> per vocabulary entry) for every core at startup, not only logprob-enabled ones — a memory and start-latency change for all deployments, justified in the author's comment as avoiding lazy init on the worker thread. It is the precondition for token_bytes() inside park() (runtime.rs:433).
6. Evidence gap narrowed but not closed (amends entry #7). New #[ignore] real-tokenizer test thinking_budget_prepares_content_headers_cut (helios/src/server/request/tml_tests.rs:355-417) asserts cut.close == [END_MESSAGE, model_tok, text_tok] against real Inkling-2-Mini tokenizer.json (not opened), reported 6/6 passing; the description also reports live flare run on GB10/SM121 across seven scenarios (Chat budget 32/64 + Unicode prompt with zero U+FFFD, tools → tool_calls, json_object, Messages budget_tokens=48, uncapped, [server] default). Still self-reported: no CI checks exist on the new head, the live runs are not reproducible from the repo, and Inkling-2-Small, vision and TP>1 are untested (read_item 615, limitations section). The central question — does a real Inkling 2 model continue in a text frame after the injected opener — is now evidenced by one model's serving transcript rather than by fixtures alone.
7. Process and community (supersedes entries #9, #11). Labels exist (area:api, enhancement, triage:review); one bot review (Changes Requested: 0 blockers / 3 should-fix / 1 subtract / 3 nits — trim heuristic, duplicated transition tokens, missing real-checkpoint verification) and one author reply 25 minutes later claiming all five groups, then @flare-autobot please re-review. No human review or comment yet, so the "zero maintainer signal" conclusion stands, now against a hostile-to-nothing bot verdict. Autobot's related/duplicate check explicitly found no file or behavioural conflict with open #457 or #582; my earlier note that #457 and #582 never cross-reference #615 is unchanged.
8. Cross-PR note that survives and matters more with #582 in flight. #582 (cc144c7c, updated 19:20) does not touch runtime.rs after all — its files are scheduler.rs (not opened), scheduler/checkpoints.rs (not opened), tests, docs, check.py (not opened) — but its blocker resolution latches zero_budget_anchor on (raw_anchor, prompt_tokens) precisely because park() grows the readmitted prompt (#582 review thread). #615 adds a shrink of up to 3 tokens on the same path, so any reviewer of both must confirm the #582 latch stays correct when the readmitted prompt length is smaller than the generated count.
Standing findings that the force-push did not fix: (a) trim/repair is applied only on forced cuts, leaving preemption and the plain output limit with the identical dangling-byte hazard (#4 in the old file, runtime.rs:2152, 2160-2162); (b) injected control tokens inflate carried.generated_tokens, record_decoded_token history and cluster metrics by up to 3 per cut, and a user token stop can cut the sequence short mid-frame — none of it in the description or docs/api.md; (c) docs/logprobs-design.md:19 (not opened) still speaks of "the thinking_token_budget close" in the singular while runtime.rs:68-70's output_event_capacity comment still says "forced token"; (d) all verification is CPU/self-reported plus one live single-GPU model, with no CI on head 7dde009; (e) the honest charter case is now narrower — the API-completeness goal is served and the model-agnostic objection is largely answered by sourcing tokens from control_tokens, but the evidence rule ("live serving, before/after", #210) is only partially met.
#15 [high] AMENDMENT (post force-push): PR #615 now head 7dde009, +614/−50 over 9 files
AMENDMENT to the case file after the new event (bot review + author force-push). Head is now 7dde009e (7dde009), +614/−50 over 9 files; labels added area:api/enhancement/triage:review. Everything in notes #1, #12 and the size/label/CI parts of #9/#11/#13 about 2652c06 and 6 files is STALE.
FILES (read_item 615, + pr_files): docs/api.md +13/−6; helios/src/output/tml.rs +13; helios/src/output/pipeline.rs +17; helios/src/server/config.rs +35/−1; helios/src/server/protocol/decode.rs +165/−1; helios/src/server/request.rs +15/−4; helios/src/server/request/tml_tests.rs +63; helios/src/server/runtime.rs +90/−30; helios/src/server/runtime/phase_tests.rs +203/−8.
WHAT CHANGED IN THE CODE (supersedes #1 and #4 items 7-8):
tml_text_transition_tokens()is DELETED from request.rs (verified: search_code pr/615 finds no match). NewOutputConfig::reasoning_close_tail()at helios/src/output/pipeline.rs:26-41 gates onsyntax.reasoning.kind == ContentHeaders+content.tools.is_empty()and callstml::text_frame_opener()(helios/src/output/tml.rs:46-57), which resolves MODEL/TEXT from the already-validated single-tokenoutput.control_tokens(pipeline.rs:22-23; populated at helios/src/model/prompt.rs:213-223 via helios/src/server/config.rs:279-280). Literals now live once at helios/src/output/tml.rs:25,29 next to CONTROL_MARKERS (tml.rs:41-44). -> Retires the "hardcoded literals in the request layer" charter objection from note #6; request prep is now format-agnostic.ReasoningCutispub close: Vec<u32>(helios/src/server/runtime.rs:50-61, field at :55); the separate close_tail and the double capacity re-check are gone. Capacity checked once at preparation: helios/src/server/request.rs:380-397 (tokens.len() + tail.len() < after as usize).- Grammar path now requires a single-token close:
cut.close.len() == 1 && grammar.allows(cut.close[0])at helios/src/server/runtime.rs:1995-1998, so a grammar never sees an injected tail. - Injection loop: helios/src/server/runtime.rs:2004-2020 via
Active::close_reasoning(); accounting at :2023-2030 (record_decoded_token per token, one cut metric,metrics.progress(0, injected.len(), ...)-> helios/src/server/metrics.rs:333-347); budget_stop truncation break at :2009-2012;remaining = cut.after.saturating_sub(injected.len())andappended = &injectedjust after :2040. - UTF-8 repair replaced by
trim_incomplete_utf8_tail()at helios/src/server/runtime.rs:417-461: concatenatesFrontend::token_bytes()for the last <=8 generated tokens, walks std::str::from_utf8(), truncates only onUtf8Error::error_len() == None; literal U+FFFD and complete chars preserved; the old "keep >=1 generated token" floor is gone so generated_len 1/2 now trim. Call site helios/src/server/runtime.rs:2156-2163, gated!appended.is_empty(). - NEW boot-time cost not in the description's bullets: helios/src/server/config.rs:281 dropped the
model.max_top_logprobs != 0gate, sofrontend.prepare_token_bytes()?buildsVocabularyBytes(helios/src/frontend/vocabulary.rs:11-45, one decoded Vec per vocab entry) for EVERY core at startup, not just logprob cores. Precondition for token_bytes() inside park (runtime.rs:433).
SURVIVING FINDINGS the force-push did NOT fix:
- Trim/repair still only on forced cuts: preemption passes
&[](park_if_preempted, helios/src/server/runtime.rs:2152) and the plain output limit is untouched -> same dangling-byte hazard there. - Injected control tokens inflate carried.generated_tokens, record_decoded_token history and cluster generated_tokens by up to 3 per cut; a user token stop can truncate the sequence mid-frame (budget_stop break, runtime.rs:2009-2012). Not stated in the description; docs/api.md:823-824 still says only "count as generated tokens", no 1-vs-3.
- Dropping up to 3 already client-visible tokens from the re-prefilled prompt is still silent; no message boundary can break because only indices >= live.prompt_tokens are touched.
- docs/api.md:821-823 now DOES state trimming applies to all reasoning formats on forced cuts (earlier doc-scope gap closed). Still stale: docs/logprobs-design.md:19 ("the thinking_token_budget close", singular) and the
output_event_capacitycomment helios/src/server/runtime.rs:68-70 ("forced token").
EVIDENCE STATE (amends #7):
- New
#[ignore]real-tokenizer testthinking_budget_prepares_content_headers_cutat helios/src/server/request/tml_tests.rs:355-417 assertscut.close == [END_MESSAGE, model_tok, text_tok]against real Inkling-2-Mini tokenizer.json; author reportsserver::request::tml_tests:: -- --ignored6/6 passed. - Author reports live
flare runon NVIDIA GB10 SM121 / Inkling-2-Mini release binary: Chat budget 32/64 + Unicode prompt (zero U+FFFD), tools -> finish_reason tool_calls get_weather, json_object -> {"answer":391}, Messages budget_tokens=48, uncapped reasoning_effort=none (0 cuts), [server] thinking_token_budget=64 with /v1/models flare.thinking_token_budget 64. - STILL self-reported: no CI checks on new head 7dde009; live runs not reproducible from the repo; Inkling-2-Small, vision, TP>1 untested (read_item 615 limitations section).
PROCESS / COMMUNITY (supersedes #9, #11): labels exist; one flare-autobot review 19:28 (Changes Requested: 0 blockers / 3 should-fix / 1 subtract / 3 nits = trim heuristic, duplicated transition tokens, missing real-checkpoint verification); author replied 19:53 claiming all five groups fixed and asked @flare-autobot to re-review; still ZERO human review or comment. Autobot's related check explicitly found no file/behaviour conflict with open #457 or #582.
CROSS-PR (amends #3): #582 is now cc144c7c and its files are docs/cli-design.md, docs/core-design.md, docs/scheduling-runtime-design.md, helios/src/scheduler.rs, helios/src/scheduler/checkpoint_lifecycle_tests.rs, helios/src/scheduler/checkpoints.rs, verification/helios-lifecycle/check.py — it does NOT edit helios/src/server/runtime.rs, so my earlier "edits the same park() path" claim was wrong. Why it still matters: #582's blocker fix latches zero_budget_anchor on (raw_anchor, prompt_tokens) precisely because park() grows the readmitted prompt (see #582 review thread, voipmonitor 2026-11-29 17:14 + FujitsuPolycom 19:20 reply). #615 adds a shrink of up to 3 tokens on the same path, so a reviewer of both must confirm the #582 latch stays correct when the readmitted prompt is shorter than the generated count.
#5 [medium] People and recent activity: first-time contributor, untouched since opening, no CI, no review
- Head 2652c06; base main at 2147cd4 per the description. The orientation packet reports "Commits on the default branch since this pull request branched (2147cd4), touching its changed files: none", but main has moved: recent helios/src commits include 0c25e88f (#613, deferred_prefill checkpoints), 9a054b49 (#608), 5df8edd3 (#607), eee6a9fa (#581) — none of them touch request.rs/runtime.rs/config.rs/decode.rs per the packet's own "touching its changed files: none", so the base is probably still mergeable but not verified.
- The PR was opened and last updated the same instant (2026-11-29 19:04) — no activity since; no CI checks on the head commit ("no checks"); no reviews, no labels (not triaged), no discussion.
- Author newjordan / "Jordan Newman" (commit 2652c067) / Discord frosty40; GitHub association FIRST_TIME_CONTRIBUTOR; 0 prior PRs or issues in 180 days. This is their first contribution.
- Who usually works here: helios/src in the last 180 days — Luke Alonso (224 commits), Martin Vit (52), yatesdr (47). The closest code (thinking budget) is yatesdr's #167; TMLv0 parser work is brandonmmusic-max (#457), yatesdr (#304, #405), and grammar work by joshua cartu (#418). docs/ is dominated by Luke Alonso (379).
- The two files with the most churn nearby: helios/src/server/runtime.rs (20+ items in 180 days) and helios/src/server/config.rs.
- Area recency that this change builds on: #167 (Nov 2) introduced the budget; #405 (Nov 20) made declared markers controls; #304/#433 brought Inkling 2 Small/Mini. So the TMLv0 ContentHeaders reasoning path is ~9 days old at PR time and the budget is ~4 weeks old; nobody had yet bridged them.
#9 [medium] Process: ready-for-review, unlabelled, zero CI, zero reviews, never updated since opening
Process state, all verified from read_item/pr_files/orientation packet:
- State: open, "ready for review" (not a draft) per the packet. Base main, head 2652c067e9dd79945fbb76ddd69c25c7907c0a05.
- No labels (not triaged as area:/triage:review; compare #457 which carries area:api, bug, model:inkling-small, triage:review).
- CI: "no checks" on the head commit. So the 1,685-test claim is unverified by automation in this repo.
- Reviews: none. Discussion: 0 comments. No autobot case file or review has been posted (unlike #457 and #582, which both got one within hours/days).
- Age: opened 2026-11-29 19:04 and never updated since. In repository time the PR is same-day as the surrounding merges (#613, #608, #607 all 2026-11-29).
- Size: +562/−31 over 6 files; 192 of those lines are one new test in protocol/decode.rs and 202 in phase_tests.rs, so production code is ~+156/−25 across request.rs, runtime.rs, config.rs (config.rs's +48 is entirely a test).
- Branch name feat/helios-tml-thinking-budget; title follows repo convention "helios: ...".
- Description quality: has Why / What changed (before → after bullets) / Claimed benefit / Supporting evidence and limitations, matching the charter's four parts; includes Discord handle (frosty40). Commit is a single squashed commit, signed "Jordan Newman".
- Community interest: none recorded — no reactions, no comments, no reviewer assigned. The only community signal is that the same-day TMLv0 PR #457 and the same-file PR #582 both drew reviews while this one drew none.
#11 [medium] Community: no comments, reviews or reactions at all; contrast with same-day neighbours
Community interest in #615 is literally zero, verified from read_item(615):
- Discussion (0): no comments, no reviews, no inline review comments, no autobot case file posted.
- No labels, no assignee, no milestone, no reactions.
- No CI checks on head 2652c06, so nothing public confirms the self-reported test runs (1,685 passed / 62 integration / 39+2 engram / flare 242).
- Contrast with neighbours in the same area/time: #457 (opened 2026-11-22) had an autobot intake report on 2026-11-24 and a full changes-requested review on 2026-11-24; #582 (opened 2026-11-28) had a human changes-requested review from voipmonitor within ~1.5 hours, an autobot case file, and a human APPROVED review on 2026-11-29. #615, opened 2026-11-29 19:04, has none of that.
- Therefore there is no evidence of either support or objection from maintainers; nothing to cite as endorsement or as a blocker beyond the PR's own text.
- The only "community" signal is the Discord handle (frosty40) and the author's FIRST_TIME_CONTRIBUTOR status; per the charter, non-priority contributors are judged on merits and reviews must spell out what is missing (#229) — so the absence of review is a process gap, not a verdict.