#1 [high] Custom/grammar tool truncation now errors instead of omitting (verified)
VERIFIED by reading head b9864ab.
Path: ResponseOutput::finish (helios/src/server/output.rs:1731-1744) on non-EOS pushes Change::End(last) for the abandoned tool block and records abandoned = Some(last). Encoder::finish (helios/src/server/protocol/encode.rs:677-689) renders those changes with frames.extend(self.change(change)?) BEFORE drop_abandoned.
Encoder::change for (Protocol::Responses, Change::End(i)) on a Block::Tool whose declared tool has custom == true does:
if self.tool(name).is_some_and(|tool| tool.custom) {
let value: Value = serde_json::from_str(arguments)
.map_err(|e| format!("invalid custom tool arguments: {e}"))?;
if !value.get("input").is_some_and(Value::is_string) {
return Err("custom tool input must be text".into());
}
(encode.rs:475-483)
A truncated call's arguments are partial JSON by construction (streamed fragments), so the ? propagates out of Encoder::finish; http.rs (helios/src/server/http.rs:534-540, 569-580) turns that into encoder.failure(&e) + Delivery::Failed, so the client gets an error frame after having been sent response.output_item.added, and never gets response.completed/response.incomplete. drop_abandoned is never reached, so blocks/calls keep the truncated call. Before this PR this path was unreachable (no Change::End was emitted for an unfinished block: close() returned Err("incomplete emitted tool call")).
No test covers it: the new protocol tests only exercise the plain function tool lookup (helios/src/server/protocol/tests.rs:3823-3827, 3992-3996).
Fix: in finish, either skip rendering Change::End through change() for abandoned blocks (render only the closing frame), or make the custom-tool branch in change() tolerate an abandoned block (pass a flag / validate only when ended).
#3 [high] Announce-before-validate reverses the pre-publication invariant and its tests
VERIFIED head b9864ab.
-
validate_argumentsnow runs AFTER fragments have been published (helios/src/output/dsml.rs:202-204:validate_arguments(&call.arguments)?;thencall.publish(self.calls, events);), whileEvent::ToolBeginwas already emitted atToolNameEnd(dsml.rs:145-156). So a call rejected for "nonempty and unique" keys, or for exceeding the 1 MiB bound (check_size, dsml.rs:42-47, called at :191), has already been announced and partly streamed to the client, then the request fails. Onmainnothing was emitted before validation (main:171-194collects intoCalland emits all three events only after validating). -
The existing test that pinned the old guarantee was rewritten rather than extended:
- helios/tests/deepseek_output.rs:514-515
assert!(error.unwrap().to_string().contains("nonempty and unique"));
assert_eq!(parsed.ended, 0, "a rejected call reported an end");
(
main:511asserted that nothing was published at all). - helios/tests/deepseek_output.rs:572-601
parse_literal_parametersnow routes events intoParsedinstead of asserting the push produced nothing. helios/src/server/output.rs:1264-1274:user_stop_cannot_retract_an_already_emitted_partial_tool_callbecameuser_stop_omits_an_already_emitted_partial_tool_call;main:1262-1270assertedErr("incomplete emitted tool call").
- helios/tests/deepseek_output.rs:514-515
assert!(error.unwrap().to_string().contains("nonempty and unique"));
assert_eq!(parsed.ended, 0, "a rejected call reported an end");
(
AGENTS.md:182-187 ("Do not remove validation, suppress errors") and 201-207 ("Apply these criteria to documentation and test changes that would weaken the rules as well as code") make this a sign-off question, not a mechanical one; docs/api.md:547-555 documents the new behaviour, so it is declared but not authorized.
#8 [high] Research summary
Reviewed PR #685 at head b9864ab for correctness, contracts and system-level consequences, reading dsml.rs, server/output.rs, server/protocol/encode.rs, pipeline.rs, http.rs, runtime.rs, latency.rs, docs/api.md, the new protocol tests and the two helios integration-test files in full context (no execution; all findings are static reading of the diff and its callers).
Seven findings saved to the scratchpad. The one I would call a real defect: a truncated custom/grammar tool call on the Responses protocol now fails the whole request. ResponseOutput::finish records the abandoned block and Encoder::finish renders its Change::End (encode.rs:677-689) through the custom-tool branch (encode.rs:475-483), which does serde_json::from_str(arguments).map_err(...)? on arguments that are partial JSON by construction, so the Err propagates out of finish and http.rs turns it into an error frame with no response.completed/response.incomplete; drop_abandoned is never reached. No new test covers a custom tool. Relatedly, for UserStop/Cancelled/ExecutionError the response.output_item.done frame for the abandoned block is rendered with item(i, true), reporting status: "completed" and partial arguments for an item that then disappears from response.completed.
Contract/charter items: the change deliberately announces a call and streams fragments before validate_arguments and the 1 MiB check_size (dsml.rs:191-204 vs main:171-194), so rejected and oversized calls reach the client before the error; the tests that pinned the old "nothing was emitted" guarantee were rewritten rather than extended (deepseek_output.rs:514-515, :572-601, output.rs:1264-1274) and docs/api.md:547-555 documents it, i.e. declared but with no maintainer sign-off against AGENTS.md:182-187/201-207. docs/api.md:543-547 is now factually false against main (the merged TAGGED_JSON parser copies the model's own JSON rather than synthesizing arguments). docs/api.md:547-549's unconditional "omitted for every termination other than EOS" is contradicted by the required/named tool_choice error at encode.rs:690-694.
Claim accuracy: the body's "ExecutionError included" describes a cause the server never passes to Encoder::finish (http.rs only forwards UserStop/Eos/OutputLimit; errors take the failure path), and the reported test counts (1787/16, output:: 113, server::protocol 96) are unchanged from the previous head despite three new test modules.
Clean areas, stated plainly: no new locks, channels or shared state — all touched structures are per-request; fragment publication copies only newly appended bytes within the 1 MiB bound; TTFT/first-response sampling (latency.rs:114-142) excludes tool-call deltas, so the rate/latency metric scope is unchanged; and the previously reported Messages/Responses framing violation is genuinely fixed (block/item closing frames now precede the terminal frame).
#9 [high] Verbatim quotes + severities for every #685 finding (correctness/contracts lens)
Head b9864ab. Static reading only; nothing executed.
F1. BLOCKER — truncated custom/grammar tool call errors the request instead of being omitted.
helios/src/server/protocol/encode.rs:475-483
if self.tool(name).is_some_and(|tool| tool.custom) {
let value: Value = serde_json::from_str(arguments)
.map_err(|e| format!("invalid custom tool arguments: {e}"))?;
if !value.get("input").is_some_and(Value::is_string) {
return Err("custom tool input must be text".into());
}
reached from helios/src/server/protocol/encode.rs:677-689:
let changes = self.outputs[index].finish(cause)?;
let abandoned = self.outputs[index].take_abandoned();
for change in changes {
...
frames.extend(self.change(change)?);
}
if let Some(block) = abandoned {
self.outputs[index].drop_abandoned(block);
}
Impact: a custom/grammar tool truncated by stop string, cancel or output limit has partial-JSON arguments; ? in change() propagates, helios/src/server/http.rs:575-580 yields encoder.failure(&e) + Delivery::Failed, so the client sees response.output_item.added then an error frame, never response.completed/response.incomplete; drop_abandoned never runs. Unreachable before this PR (close() returned Err("incomplete emitted tool call"), output.rs main:1717-1731). No test: protocol/tests.rs:3823-3827 and :3992-3996 use only function tool "lookup".
Fix: do not render an abandoned block's Change::End through the custom-tool validation path (pass an abandoned/"closing-only" flag into change() and skip validation), or validate custom input only when the block ended.
F2. MAJOR — abandoned item reported as completed with partial arguments (Responses, non-output-limit causes).
helios/src/server/protocol/encode.rs:340-346
let status = if self.incomplete_item == Some(index) {
"incomplete"
} else if complete {
"completed"
} else {
"in_progress"
};
incomplete_item is set only for OutputLimit (encode.rs:680-683); Change::End calls self.item(i, true) (encode.rs:486) and emits response.output_item.done (encode.rs:513-516) with "arguments":if complete{arguments.as_str()}else{""} (encode.rs:380-381). Impact: on UserStop/Cancelled/ExecutionError the client gets status:"completed" and truncated arguments for an item absent from response.completed. Fix: mark the abandoned index incomplete (or omit arguments) for every drops_unfinished_call cause.
F3. BLOCKER (authorization) — announce/stream precedes validation and the 1 MiB check.
helios/src/output/dsml.rs:194-206
OutputAction::ToolCallArgumentsEnd { closing_text } if !repeated => {
...
call.close_literal();
call.arguments.push_str(closing_text);
call.check_size()?;
validate_arguments(&call.arguments)?;
call.publish(self.calls, events);
events.push(Event::ToolEnd { index: self.calls });
with Event::ToolBegin already emitted at dsml.rs:145-156. main:171-194 emitted none of the three until after validate_arguments. Rejected ("nonempty and unique") and oversized (>1 MiB) calls now reach the client before the error. Tests were inverted to bless it: helios/tests/deepseek_output.rs:514-515 assert_eq!(parsed.ended, 0, "a rejected call reported an end"); (main:511 asserted nothing published), helper :572-601, and helios/src/server/output.rs:1264-1274 (user_stop_omits_an_already_emitted_partial_tool_call; main:1262-1270 asserted Err("incomplete emitted tool call")). AGENTS.md:182-187 + 201-207 require a maintainer decision; none on record.
F4. MAJOR (claim accuracy) — ExecutionError arm unreachable in production.
helios/src/server/http.rs:526-540 forwards only the Finished.termination from runtime.rs:2366-2371 (UserStop / Eos / OutputLimit); generation errors take GenerationEvent::Error(e) => Err(e) (http.rs:562) → encoder.failure (http.rs:576). So drops_unfinished_call's ExecutionError branch (helios/src/server/output.rs:478-480) and the test rows at protocol/tests.rs:3816 and :3985 exercise a path the server never hits. PR body's "ExecutionError included" overstates live coverage.
F5. MAJOR (docs vs code) — required/named tool_choice truncation still errors.
helios/src/server/protocol/encode.rs:690-694
if matches!(self.tool_choice, ToolChoice::Required | ToolChoice::Named(_))
&& !self.outputs[index].has_tools()
{
return Err("required tool choice was not satisfied: the model did not produce a completed tool call".into());
}
contradicts new docs/api.md:547-549 ("omitted from a buffered response for every termination other than natural end-of-sequence"). reasons[index] is never set (:702) so no terminal frame is emitted; http.rs:575-580 sends an error frame. Not a regression, but the doc rule is unconditional. Fix: qualify the doc, or skip the required-tool error when drops_unfinished_call(cause).
F6. MAJOR (docs) — docs/api.md:543-547 false against main. "The tagged tool parsers publish a call only when its envelope is complete, because they build its arguments from parameter syntax and the declared schemas rather than copying the model's text". main now has helios/src/output/tagged_json.rs (merged #670) which parses the model's own JSON object. This PR edits those exact lines.
F7. MINOR (claim accuracy) — stale numbers. Body still reports "1787 passed and 16 failed", "output:: 113 passed", "server::protocol 96 passed"; b9864ab adds mod streaming_tests (dsml.rs:749-985), mod rejection_tests (dsml.rs:987-1033) and protocol tests.rs:3809-4017. No CI run on any hash.
CLEAN (state plainly, do not invent issues): per-request state only, no new locks/channels/global state (Encoder built per request, http.rs:358-400); Call::publish copies only new bytes within the 1 MiB bound (dsml.rs:53-62, :42-47); TTFT metric unaffected — helios/src/server/latency.rs:114-142 counts only content/reasoning deltas; the earlier Messages/Responses unclosed-block framing bug is genuinely fixed (content_block_stop encode.rs:424-428 and response.output_item.done :513-516 precede message_stop :735-739 / response.completed :740-750; asserted at protocol/tests.rs:3861-3876); decode/emit ordering preserved; no cross-platform (Unix/Windows) surface touched by this change.
Known limitation, not a defect: frame count now scales with model fragments (566 frames / 2196 bytes measured by the author) instead of with calls — intended by the PR.
#2 [medium] Responses output_item.done for a truncated call claims status completed with invalid arguments
VERIFIED head b9864ab.
incomplete_item is only set for Termination::OutputLimit (helios/src/server/protocol/encode.rs:680-683). For UserStop, Cancelled and ExecutionError the abandoned block is rendered by Change::End, which calls let item = self.item(i, true); (encode.rs:486) and emits response.output_item.done (encode.rs:513-516).
item() computes let status = if self.incomplete_item == Some(index) { "incomplete" } else if complete { "completed" } else { "in_progress" }; (encode.rs:340-346) and for a function tool emits "arguments":if complete{arguments.as_str()}else{""} (encode.rs:380-381).
So on a user stop / cancel / execution error inside a streamed call the client receives response.output_item.done with status: "completed" and arguments holding a partial JSON string, while the same item is then dropped (drop_abandoned, output.rs:1750-1755) and absent from response.completed. Ordering of the frames is otherwise corrected (content_block_stop / output_item.done now precede the terminal frame), so this is a residual item-level inconsistency rather than the old unclosed-block bug.
#4 [medium] Claim accuracy: ExecutionError arm is unreachable from the server; test counts stale
VERIFIED head b9864ab.
-
PR body: "
Accumulator::finish(cause)andResponseOutput::finish(cause)now drop an announced-but-unfinished call through one predicate ...ExecutionErrorincluded;Encoder::finishpasses the cause ... toResponseOutputunconditionally." The server never callsEncoder::finishwithTermination::ExecutionError: helios/src/server/http.rs:534-540 passesterminationtaken fromGenerationEvent::Finished { termination, .. }(http.rs:518-524), and the runtime only producesUserStop(runtime.rs:2065, 2366-2367),Eos(runtime.rs:2369) orOutputLimit(runtime.rs:2371). A generation error goes throughGenerationEvent::Error(e) => Err(e)(http.rs:562) and thenencoder.failure(&e)(http.rs:576-577), neverfinish. So theExecutionErrorarm ofdrops_unfinished_call(helios/src/server/output.rs:478-480) and the ExecutionError rows in the new tests (protocol/tests.rs:3816, 3985) exercise a path production does not take. Harmless, but the PR body's "ExecutionError included" overstates live coverage. -
Test numbers in the body ("1787 passed and 16 failed", "output:: 113 passed", "server::protocol 96 passed") are unchanged from the earlier head and cannot reflect this head: b9864ab adds
mod streaming_tests(dsml.rs:749-985),mod rejection_tests(dsml.rs:987-1033) and three protocol tests (protocol/tests.rs:3809-4017). Self-reported only; no CI run on any hash of this branch. -
The
_ => {}literalEncoder::finishreachability aside, theabandonedbookkeeping is sound for the non-custom case:Change::Endis rendered beforedrop_abandoned(encode.rs:677-689),drop_abandonedguardsindex + 1 == blocks.len()(output.rs:1750-1755), andclose()still rejects EOS-leftover and non-tail unfinished calls (output.rs:1721-1730).
#5 [medium] System-level consequences: concurrency, memory, metrics all clean except frame count growth
VERIFIED head b9864ab (per-request state, no shared locks).
- All touched state is per-request:
DsmlOutput(dsml.rs:81-95),Accumulator/ResponseOutput(output.rs:58-63, 1698-1704) andEncoder(encode.rs:122-159) are constructed per request inhttp.rs(state.rs / http.rs:358-400). No new mutex, channel or global; no head-of-line blocking added. - Memory:
Call::publish(dsml.rs:53-62) slicesarguments[published_argument_bytes..]andto_owned()s only newly appended bytes, so total copied bytes are bounded by the 1 MiB argument bound (dsml.rs:22, 42-47).ResponseOutput::applyappends the same fragment intoarguments(output.rs:1817-1835, 8 MiB bound at :1830) and pushes oneChange::Deltaper fragment, i.e. one SSE frame per model fragment — the intended behaviour (the PR measured 566 frames / 2196 bytes). Streaming frame count now scales with generation tokens instead of with calls; forparallel_tool_calls/multi-choice that is per-choice, still linear in output bytes. - Failure propagation: the one real blast-radius item is the custom-tool
Err(scratchpad entry 1): the whole request becomes an error frame instead of a truncated-but-valid response. - Metric span check:
stream_text(helios/src/server/latency.rs:114-142) only counts content/reasoning deltas, and it inspectsdelta.content,delta.reasoning_content,text, and Messages/Responses text deltas — tool-call argument deltas are excluded, so first-response/TTFT sampling is unchanged by this PR.Message/usagemetrics unaffected:usage_valueand finish reasons are computed from the accumulator, and a dropped call simply does not count. - Ordering: fragments and
ToolEndare emitted into the sameVec<Event>in decode order, andEncoder::applypreserves it; the Responses/Messages delta ordering is unchanged. The only ordering hazard was the unclosed block, which is now fixed (content_block_stop at encode.rs:424-428 precedes message_stop at :735-739; output_item.done at :513-516 precedes response.completed at :740-750) — confirmed by protocol/tests.rs:3861-3876.
#6 [medium] docs/api.md tagged-parser sentence is false against main (TAGGED_JSON)
VERIFIED head b9864ab.
docs/api.md:543-547 still states: "The tagged tool parsers publish a call only when its envelope is complete, because they build its arguments from parameter syntax and the declared schemas rather than copying the model's text". main now contains helios/src/output/tagged_json.rs (present in list_files main helios/src/output/*.rs; introduced by merged #670) which parses the model's own {"name":…,"arguments":…} JSON object instead of synthesizing arguments from parameter syntax. So the doc sentence is factually false against main after this PR's rebase-free description of parsers. This PR touches those exact lines (its +25/-12 in docs/api.md covers 540-575), so the PR is the place to fix or the rebase will land false documentation.
Also unchanged from the earlier head and still true: docs/api.md:568-572 states the 1 MiB bound "is enforced on the append that crosses it, after the call name and earlier argument fragments were published and are not retracted" — i.e. #364's publish-after-check property stays reversed, and it is now documented as such.
#7 [medium] Required/named tool_choice truncation still returns an error frame, contradicting new docs
VERIFIED head b9864ab.
docs/api.md:547-549: "An announced call cut off before completion is omitted from a buffered response for every termination other than natural end-of-sequence, and the response reports that termination's finish reason; only an output-limit termination reports the output limit."
But Encoder::finish still errors after omitting the call when the request demanded a tool:
if matches!(self.tool_choice, ToolChoice::Required | ToolChoice::Named(_))
&& !self.outputs[index].has_tools()
{
return Err("required tool choice was not satisfied: the model did not produce a completed tool call".into());
}
(helios/src/server/protocol/encode.rs:690-694, after drop_abandoned at :687-689)
With tool_choice: "required" (or a named tool) plus streaming truncation, has_tools() is false because the call was popped, so the ? returns early: self.reasons[index] is never set (:702), no terminal frame is emitted (:709-752), and helios/src/server/http.rs:575-580 converts it into encoder.failure(&e) — an error frame — instead of the documented truncated response. Not a regression (on main the same request failed one line earlier with "incomplete emitted tool call"), but the new documentation states an unconditional rule that the required/named tool-choice path contradicts. Fix: qualify the sentence, or skip the required-tool error on drops_unfinished_call(cause) terminations so the truncation is reported as documented.