Recommendation: Changes Requested
The incremental DSML streaming core (DsmlOutput::apply + Call::publish with published_argument_bytes and string="false" literal deferral) is clean, byte-exact, and avoids per-model shared-layer branches, concurrency hazards, or TTFT regressions, and b9864ab fixes the four previously broken helios/tests/ integration tests and the Messages closing-frame order. However, the new Change::End-before-drop path in b9864ab introduces a concrete regression that fails Responses requests (both streaming and non-streaming) whenever a custom tool call is truncated, and the PR still reverses reviewed pre-publication (#364) and non-EOS incomplete-call error contracts across code, tests, and docs without explicit maintainer sign-off (AGENTS.md:182-187, 201-207).
Merge Risk
Level: High
- Direct regression on Responses
customtool truncation (streaming and buffered): RenderingChange::Endfor an abandoned tool block beforedrop_abandonedroutes partial JSON arguments intoEncoder::change's custom-tool JSON/grammar validator (helios/src/server/protocol/encode.rs:475-484, 502-505, 677-689), turning truncated DeepSeek custom-tool calls that succeeded asincomplete/completedonmainintoresponse.failed(streaming) or HTTP 500 errors (helios/src/server/http.rs:575-580, 639). - Unapproved contract reversals across all parsers and protocols:
drops_unfinished_call(helios/src/server/output.rs:163-173, 478-480, 1731-1744) replacesmain's non-EOSErr("incomplete emitted tool call")with silent omission across all tool parsers and wire protocols, while DSML streaming publishesToolBegin/ToolArgumentsprior tovalidate_argumentsand#364's 1 MiB bound (helios/src/output/dsml.rs:145-156, 191-206), accompanied by weakened tests (helios/tests/deepseek_output.rs:514-515,helios/src/server/output.rs:1265-1274) without maintainer approval. - No concurrency, memory, or TTFT regressions: All modified state (
DsmlOutput,Accumulator,ResponseOutput,Encoder) is strictly per-request (helios/src/server/http.rs:358-400);Call::publishslices newly appended bytes within the 1 MiB buffer (withstart >= published_argument_bytespreserved acrossclose_literal), strict-tool parking (encode.rs:585-624) remains intact, andstream_text(helios/src/server/latency.rs:116-142) excludes tool-call deltas so TTFT sampling is unchanged.
Walkthrough
- Incremental DSML publication (
helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): EmitsEvent::ToolBeginatToolNameEnd, tracksCall::published_argument_bytesand publishesEvent::ToolArgumentsfragments after eachToolCallArgumentsTextappend (keepingstring="false"literals unpublished untilclose_literalsettles them), and flushes remaining bytes plusEvent::ToolEndaftervalidate_argumentsatToolCallArgumentsEnd. - Non-EOS unfinished-call omission and closing-frame order (
helios/src/server/output.rs:163-173, 478-480, 1703, 1731-1755,helios/src/server/protocol/encode.rs:674-689): Addsdrops_unfinished_call(cause) -> cause != Termination::Eos, passescauseintoAccumulator::finishandResponseOutput::finish, emitsChange::End(last)for a truncated trailing tool block beforedrop_abandonedpops it, and omits it from the buffered body. - Mechanical test call-site updates (8 files) & inverted/updated tests: Threads
Termination::Eosintooutput.finish(...)acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs, andserver/runtime/phase_tests.rs; rewritesuser_stop_cannot_retract_an_already_emitted_partial_tool_call(helios/src/server/output.rs:1265-1274) and updates integration tests inhelios/tests/deepseek_output.rs:499-515, 572-601andhelios/tests/deepseek_requests.rs:683-693for incremental DSML events. - New unit tests and API documentation (
helios/src/output/dsml.rs:749-1033,helios/src/server/protocol/tests.rs:3809-4090,docs/api.md:540-574): Adds DSML streaming/split/literal-deferral/truncation/rejection tests, Chat/Messages/Responses truncation and end-to-end DSML→Chat tests, and updatesdocs/api.mdfor DSML streaming, non-EOS omission, and post-publication 1 MiB enforcement.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or instruction-hijacking patterns; 1 MiB parser (
helios/src/output/dsml.rs:22, 42-47, 234-236) and 8 MiB response (helios/src/server/output.rs:119-121, 1830-1832) bounds remain enforced. - [WARN] Charter & value fit: Directly serves the charter's coding-agent/heavy-tool-use vision with no per-model shared-layer branch, but has no linked issue/maintainer request and reverses reviewed
#364pre-publication and non-EOS error invariants without maintainer sign-off (AGENTS.md:182-187, 201-207). - [WARN] Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with
#670(itsdocs/api.mdadditions begin at line 610 onmain), but#670addedTAGGED_JSON(helios/src/output/tagged_json.rs:14-49, 57onmain), makingdocs/api.md:543-547factually false againstmain;#364's pre-publication 1 MiB guarantee is reversed. - [WARN] Tests & verification evidence: No CI run on
b9864ab; self-reported counts in the PR body were run with--libonly (omittinghelios/tests/, which was edited inb9864aband is run unconditionally by.github/workflows/native-serving.yml:63 (not opened), 68), andflare/flare-cliwere not built or tested (docs/design-review.md:180-185).
Blockers
-
Truncated
customtool calls on Responses now fail the entire request instead of being omitted (helios/src/server/protocol/encode.rs:470-485, 502-505, 677-689;helios/src/server/output.rs:1731-1744).- Verified behavior & impact: When a
customtool call (tool.custom == true) is truncated byOutputLimitorUserStop,ResponseOutput::finish(cause)emitsChange::End(last)beforedrop_abandonedpops the block.Encoder::finishrenders thatChange::EndthroughEncoder::change(encode.rs:685), which executesserde_json::from_str(arguments)?(:476-477), checksvalue.get("input").is_some_and(Value::is_string)(:478-480), runsgrammar.validate(...)(:481-483), and checksitem["input"].is_string()(:503-505). Because an abandoned call'sargumentsare empty or partial JSON by construction,Encoder::finishreturnsErr("invalid custom tool arguments: ..."),drop_abandonednever runs, streaming Responses requests fail withresponse.failed(helios/src/server/http.rs:575-580), and non-streaming Responses requests return an HTTP error (http.rs:639). This is a direct regression againstmain, whereDsmlOutputbuffered and discarded incomplete calls so both streaming and buffered Responses requests succeeded cleanly asincomplete/completed. - Fix: Pass whether
Change::End(i)is closing an abandoned block intoEncoder::change(or checkabandoned == Some(i)), skip custom-tool JSON/grammar validation andresponse.custom_tool_call_input.{delta,done}emission for abandoned blocks, and emit only the closingresponse.output_item.donewith"status": "incomplete"before discarding the block. Add a Responses protocol test covering a truncatedcustomtool call for both streaming frames and bufferedresponse().
- Verified behavior & impact: When a
-
Reversal of reviewed pre-publication, size-bound, and non-EOS error invariants without maintainer sign-off (
helios/src/output/dsml.rs:145-156, 191-206;helios/src/server/output.rs:163-173, 478-480, 1265-1274;helios/tests/deepseek_output.rs:514-515;docs/api.md:547-551, 568-572).- Verified behavior & impact: Streaming DSML arguments before
ToolCallArgumentsEndinherently publishesToolBeginandToolArgumentsfragments beforevalidate_argumentsand before subsequent appends cross#364's 1 MiB bound (maindocs/api.md:560andhelios/tests/deepseek_output.rs:511pinned "nothing published before validation/size check";b9864abweakens:515toassert_eq!(parsed.ended, 0)). Separately,drops_unfinished_callreplacesmain's non-EOSErr("incomplete emitted tool call")(pinned bymainhelios/src/server/output.rs:1257-1271,user_stop_cannot_retract_an_already_emitted_partial_tool_call, rewritten here to assert omission) across all tool parsers and wire protocols. UnderAGENTS.md:182-187, 201-207, weakening existing validation/error guarantees — including via accompanying doc and test rewrites — requires an explicit maintainer design decision on record before merging. - Fix: Obtain explicit maintainer sign-off (e.g., from
@yatesdr/@voipmonitor, who reviewed/authored#364and the retraction semantics) recorded on this PR confirming (a) post-publication validation/1 MiB enforcement for streaming DSML calls and (b) non-EOS unfinished-call omission across protocols.
- Verified behavior & impact: Streaming DSML arguments before
Should Fix
-
Responses
response.output_item.donereportsstatus: "completed"with partial JSON arguments for non-OutputLimittruncated calls (helios/src/server/protocol/encode.rs:339-346, 381, 486, 509, 513-516, 680-685).self.incomplete_item = Some(i)is set only whencause == Termination::OutputLimit(encode.rs:680-684). OnUserStop(orCancelled),Change::Endrendersself.item(i, true)with"status": "completed"and partial JSON in bothresponse.function_call_arguments.doneandresponse.output_item.done, right beforedrop_abandoneddeletes that item fromresponse.completed'soutput.- Fix: Set
self.incomplete_item = Some(i)wheneverabandoned == Some(i)(not only onOutputLimit), clearself.incomplete_item = Noneafter thefor change in changesloop, and extend the Responses truncation test to assertstatus == "incomplete"for all non-EOS causes.
-
docs/api.md:547-550states an unconditional truncation-omission rule contradicted bytool_choice: Required | Named(helios/src/server/protocol/encode.rs:690-694).docs/api.md:547-550claims an announced call cut off before completion is omitted and the response reports that termination's finish reason for every non-EOS termination. However, afterdrop_abandoned, if no completed tool call remains andtool_choiceisRequiredorNamed(_),encode.rs:690-694returnsErr("required tool choice was not satisfied: ..."), ending the request in an error frame / HTTP error.- Fix: Qualify
docs/api.md:547-550to note thattool_choice: "required"or a named tool still errors when omitting the truncated call leaves no completed tool call (and add a test pinning the intended behavior).
-
docs/api.md:543-547is factually false againstmainafter#670(TAGGED_JSON).docs/api.md:543-547states that all tagged tool parsers buffer "because they build its arguments from parameter syntax and the declared schemas rather than copying the model's text: values are coerced to declared types, strict container parameters are parsed, and wrapping newlines are trimmed." Onmain,TAGGED_JSON(helios/src/output/tagged_json.rs:14-49, 57,JSON_BODY = true,TRIM_NEWLINES = false) parses the model's JSON object directly without parameter syntax, schema coercion, or newline trimming.- Fix: Delete the over-generalized
"because ... trimmed."clause so line 543-544 states simply:"The tagged tool parsers publish a call only when its envelope is complete."(The per-dialect details are already documented atdocs/api.md:601-638onmain.)
Subtract / Simplify
-
Restore
Accumulator::finish(&self)and remove 8 files of mechanical test churn (helios/src/server/output.rs:163-173;helios/src/server/protocol/encode.rs:674-676; 8 test-only files).Accumulator::finish(&mut self, cause: Termination)usescauseonly to evaluatedrops_unfinished_call(cause), forcing ~25 call sites acrossargument_tags.rs,chatml.rs,gemma_call.rs,minimax_xml.rs,pipeline.rs,xtml.rs,runtime_core/protobuf.rs,server/runtime/phase_tests.rs,dsml.rs, andserver/output.rsto passTermination::Eos.- Simplification: Keep
Accumulator::finish(&self) -> Result<()>unchanged frommain, addpub(crate) fn discard_unfinished_call(&mut self)(4 lines), and call it beforefinish()at the single production site (encode.rs:674-676, plusPresentation::finishatoutput.rs:501-505). This deletes 8 entire files from the diff.
-
Collapse
take_abandoned+drop_abandoned(index)intodiscard_abandoned(&mut self)(helios/src/server/output.rs:1745-1755;helios/src/server/protocol/encode.rs:678, 687-689).ResponseOutput::finishalways setsself.abandoned = Some(self.blocks.len() - 1)and renderingchangesnever mutatesself.blocks, so round-trippingindex: usizeout throughtake_abandonedand back intodrop_abandonedwith the unreachableif index + 1 == self.blocks.len()guard adds surface area without value. Replacetake_abandoned/drop_abandoned(index)with a read accessoris_abandoned(&self, index: usize) -> bool(needed for Blocker #1 / Should Fix #1) plus a singlepub fn discard_abandoned(&mut self)that popsblocksandcallswhenself.abandoned.take().is_some().
-
Fold the duplicated header-only vs mid-argument truncation matrix tests (
helios/src/server/protocol/tests.rs:3809-3907, 3979-4017;helios/src/output/dsml.rs:917-937, 962-984).- Both pairs repeat the same loop/assertion body differing only in whether argument fragments were pushed, and
protocol/tests.rs:3982-3986already drifted by omittingTermination::Cancelledand the closing-frame assertions (:3861-3876). Parameterizing each pair over empty vs non-empty fragments removes ~70 lines and keeps one authoritative cause list.
- Both pairs repeat the same loop/assertion body differing only in whether argument fragments were pushed, and
Nits
- Refresh verification evidence on the current head (
b9864ab): Re-run the fullheliostest suite without--lib(covering the editedhelios/tests/deepseek_output.rsandhelios/tests/deepseek_requests.rs), plusflareandflare-cliperdocs/design-review.md:180-185, and update the PR body's test counts.
Dropped on verification
- Subtraction #2 sub-claim that
matches!(self.blocks.last(), Some(Block::Tool { .. }))athelios/src/server/output.rs:1735is dead whenself.open.is_some(): False.self.opentracks openBlock::TextandBlock::Reasoningblocks as well asBlock::Tool(output.rs:1781, 1814); deleting theBlock::Toolcheck would erroneously abandon and drop the final text or reasoning block onOutputLimit/UserStop. - Correctness F8 ("MAJOR:
ExecutionError includedoverstates live coverage"): Over-flagged. The PR description accurately states that the predicatedrops_unfinished_call(cause)holds for every cause exceptEos,ExecutionErrorincluded; it does not claimhttp.rsroutesGenerationEvent::ErrorthroughEncoder::finish(http.rs:562, 576routes runtime errors toencoder.failuredirectly). - Upstream dossier/lens claim that
b9864abaddedmod streaming_tests,mod rejection_tests, and the three protocol tests (making test counts stale specifically due to those modules): Inaccurate. Prior review walkthroughs confirm those modules were already present at2f0ed9dand80c87b3;b9864abadded only thehelios/tests/updates and the closing-frame fix/assertions. - Unmodified
helios/tests/deepseek_requests.rs:404(events.contains(ToolArguments { text: "{}" })) check: Verified safe — that test uses a zero-parameter<|DSML|invoke name="lookup"></|DSML|invoke>, so"{}"is still published as a singleEvent::ToolArgumentsatToolCallArgumentsEnd. - Upstream
docs/api.md:550-551deletion suggestion ("A client that received fragments of such a call has already seen a call that cannot complete"): Low-signal prose preference; kept out ofSubtract / Simplifybecause explicitly documenting the streaming-vs-buffered divergence is genuinely helpful to API consumers once maintainers approve the contract.