#1 [high] Verified: truncated call leaves Messages/Responses block unclosed (framing)
PR #685 head 80c87b3. helios/src/server/output.rs:1730-1742:
pub fn finish(&mut self, cause: Termination) -> Result<Vec<Change>> {
if drops_unfinished_call(cause)
&& self.open.is_some()
&& matches!(self.blocks.last(), Some(Block::Tool { .. }))
{
self.blocks.pop();
self.calls.pop();
self.open = None;
}
let mut changes = vec![];
self.close(&mut changes)?;
Ok(changes)
}
self.open = None here means close() (output.rs:1720-1729) — the ONLY producer of Change::End — emits nothing for the popped block.
Change::Start for that block was already streamed: helios/src/server/protocol/encode.rs:409-415 (content_block_start, Messages) and encode.rs:430-434 (response.output_item.added, Responses). Change::End is the only source of content_block_stop (encode.rs:424-428) and response.output_item.done/response.function_call_arguments.done (encode.rs:470-516).
Encoder::finish (encode.rs:658-748) then emits terminal frames unconditionally: message_delta+message_stop (encode.rs:730-734), response.incomplete/response.completed (encode.rs:735-745). So an SSE Messages/Responses stream announces a tool_use/function_call block, streams input_json_delta/response.function_call_arguments.delta, then terminates with message_stop / response.completed and no content_block_stop / output_item.done. Contradictory: message_delta.delta.stop_reason is end_turn (response() excludes the popped block, encode.rs:810) while the stream opened a tool_use block.
PR's own 3 new protocol tests (helios/src/server/protocol/tests.rs:3809-3995) assert only encoder.response(), never the frame sequence, so they miss it.
Fix: keep the block but mark it dropped, emit Change::End(index) for it, and filter it out of response()/item() iterators (encode.rs:810 (0..self.outputs[0].blocks.len()), encode.rs:828).
#2 [high] Research summary
Reviewed PR #685 at head 80c87b3 through the correctness/contracts/system-consequences lens: read the full diff of dsml.rs, server/output.rs, encode.rs, protocol/tests.rs and docs/api.md, plus their callers (server/http.rs streaming loop, runtime.rs termination mapping, latency.rs TTFT sampling, request.rs/prepare path for structured), and the pre-existing helios/tests/ integration tests CI actually runs.
Three verified defects stand out. (1) Blocker: an announced-but-unfinished tool block is popped from ResponseOutput before close(), so the sole producer of Change::End never fires, yet Encoder::finish still emits message_delta/message_stop and response.incomplete/response.completed — a Messages/Responses SSE client receives an open content_block_start/response.output_item.added and no matching stop/done frame, with a contradictory stop_reason. The PR's three new protocol tests assert only the buffered body, never the frame stream, so they miss it. (2) Blocker/Major: four existing integration tests in helios/tests/deepseek_output.rs and helios/tests/deepseek_requests.rs assert the pre-streaming contract and will fail under the workflow that runs the whole helios test target — the author's --lib-only evidence cannot see them. (3) Major: the universal drops_unfinished_call(cause) -> cause != Eos turns a request-level error into a success with a stop/end_turn finish reason for UserStop, Cancelled and ExecutionError, and docs/api.md documents the new behaviour as if it were the intended contract — a weakening of a signed-off invariant with no maintainer decision on record (AGENTS.md:182-187, 201-207).
Also recorded: the DSML publish/close_literal deferral itself is sound and byte-exact, the strict-tool parking path is genuinely unchanged, and the added state is strictly per-request with no contention, memory-amplification or TTFT-sampling change — stream_text (latency.rs:116-142) does not count tool deltas, so the added frames do not move first-response metrics. Details and citations are in the scratchpad.
#3 [high] Verified: CI integration tests broken (author ran --lib only)
PR #685 @80c87b3. CI test commands (no --lib) — .github/workflows/native-serving.yml:63 (Linux) and :68 (Windows):
cargo test --locked --release --manifest-path helios/Cargo.toml --target-dir flare-cli/target --features runtime-core,server
The PR touches no helios/tests/ file (13 files, all helios/src/ + docs). The PR body's evidence is cargo test ... --features runtime-core,server --lib — structurally cannot see these.
Failures, statically verified against the diff:
helios/tests/deepseek_output.rs:576in the shared helperparse_literal_parameters(568-593):
let header = format!("{open}<|DSML|{s}invoke name=\"lookup\">");
assert!(output.push(Input::Text(&header))?.is_empty());
and :581:
assert!(output.push(Input::Text(¶meter))?.is_empty());
The header push now emits Event::ToolBegin at helios/src/output/dsml.rs:151-155, and non-string parameters publish Event::ToolArguments (dsml.rs:192). This helper drives tool_call_size_includes_retained_strings_and_closing_brace_in_either_order (595-619) and literal_nesting_includes_the_enclosing_argument_object (621-635).
helios/tests/deepseek_output.rs:511inempty_and_duplicate_top_level_parameter_names_are_rejected:
assert!(error.unwrap().to_string().contains("nonempty and unique"));
assert!(published.is_empty());
validate_arguments (dsml.rs:202) now runs after ToolBegin (dsml.rs:151) and after per-fragment publish (dsml.rs:192), so published is non-empty. (The PR's own new test a_rejected_argument_object_fails_after_its_fragments_are_published, dsml.rs:1015+, asserts the opposite behaviour.)
helios/tests/deepseek_requests.rs:684inadded_non_special_dsml_token_produces_tool_calls:
assert!(events.iter().any(|event| matches!(event,
flare_helios::output::Event::ToolArguments { text, .. } if serde_json::from_str::<Value>(text).unwrap() == json!({"location":"Berlin"}))));
unwrap() on a single fragment; fragments are now partial JSON ({"location": , "Berlin", }), so it panics.
Concrete fix: update the three assertions to the streaming contract (header push yields exactly one ToolBegin; each parameter push yields either empty or argument fragments; drop the published.is_empty() assertion; concatenate fragments before serde_json::from_str), or gate on a per-event shape. This is independent of the framing defect and would fail CI on merge.
Note: other helios/tests DSML sites already concatenate (deepseek_requests.rs:875-882, :920-924; deepseek_output.rs:40 accumulates into calls[index].1), so they pass.
#4 [high] Verified: universal drop turns request errors into success (guarantee weakened)
PR #685 @80c87b3. helios/src/server/output.rs:476-480:
/// Whether a termination cause drops a tool call that was announced but never
/// completed, instead of reporting it as an incomplete call.
pub(crate) fn drops_unfinished_call(cause: Termination) -> bool {
cause != Termination::Eos
}
Applied in Accumulator::finish (output.rs:163-173):
pub(crate) fn finish(&mut self, cause: Termination) -> Result<()> {
if drops_unfinished_call(cause)
&& self.calls.last().is_some_and(|call| !call.ended)
{
self.calls.pop();
}
if self.calls.iter().any(|call| !call.ended) {
return Err("incomplete emitted tool call".into());
}
and ResponseOutput::finish (output.rs:1730-1742), and threaded from Encoder::finish (encode.rs:674-677) which passes the cause to chats[index] and outputs[index].
Consequence: for UserStop, Cancelled and ExecutionError a request that previously failed with Err("incomplete emitted tool call") now succeeds with an empty/lossy body. Finish reason (encode.rs:690-696):
let reason = if cause == Termination::OutputLimit { "length" }
else if cause != Termination::UserStop && self.outputs[index].has_tools() { "tool_calls" }
else { "stop" };
so Chat reports stop, Messages maps to end_turn (encode.rs:810), Responses to completed. A downstream agent loop sees a successful empty completion instead of an error — the PR body never frames it this way ("for every cause except natural end-of-sequence, ExecutionError included").
ExecutionError is the sharpest case: on that path Decoder::finish already aborts and the parser discards its state (helios/src/server/output.rs:341-348, helios/src/output/dsml.rs:382-386 clears pending/call), so the announced ToolBegin streamed earlier is the only trace, and the drop silently converts a failed execution into a 200-class empty response.
The PR also inverts the test that pinned the invariant — helios/src/server/output.rs:1265-1274:
fn user_stop_omits_an_already_emitted_partial_tool_call() {
...
presentation.finish(Termination::UserStop).unwrap();
assert!(presentation.message().get("tool_calls").is_none());
}
(formerly user_stop_cannot_retract_an_already_emitted_partial_tool_call, asserting the "incomplete emitted tool call" error).
Charter/AGENTS.md:182-187 — "Reject weakened guarantees. … Do not remove validation, suppress errors, silently substitute execution paths…"; AGENTS.md:201-207 — "A feature request, passing tests, or a performance gain does not waive an architectural invariant. Resolve conflicts through an explicit maintainer decision on the design… Apply these criteria to documentation and test changes that would weaken the rules as well as code." Code, test and docs all change; no maintainer decision found in the tracker.
Concrete fix: narrow the predicate to the causes that actually need it (OutputLimit only, which is what OutputLimit omission already did on main), keeping Err for UserStop/Cancelled/ExecutionError; or, if drop-on-truncate is wanted, emit an explicit machine-readable truncation signal and get maintainer sign-off on the design first.