Skip to content

fix(frontend): stream DeepSeek tool-call arguments - #685

Open
peperunas wants to merge 4 commits into
NVIDIA:mainfrom
peperunas:fix/dsml-tool-call-streaming
Open

peperunas wants to merge 4 commits into
NVIDIA:mainfrom
peperunas:fix/dsml-tool-call-streaming

Conversation

@peperunas

@peperunas peperunas commented Dec 2, 2026 •

Copy link
Copy Markdown

A DeepSeek tool call now reaches the client as the model writes it: the call's name is announced when its header completes, and its argument text is published fragment by fragment instead of arriving whole when the invoke tag closes.

The pinned deepseek-recipe parser already releases each argument label and text fragment as it decodes input, but DsmlOutput collected them and emitted the begin, arguments and end events together at ToolCallArgumentsEnd. A client therefore received nothing between the tool name and the finished argument object: a multi-kilobyte write argument left the stream silent for the whole generation, which a client renders as a stalled response and an agent loop cannot tell apart from a hung model. The encoder and both block emitters already open a tool call on Event::ToolBegin and forward each Event::ToolArguments fragment, so the defect was confined to when the parser published them.

DsmlOutput::apply now emits Event::ToolBegin at ToolNameEnd, publishes the argument bytes appended by each argument-text action and the rest at ToolCallArgumentsEnd, so label bytes travel with the next text fragment or that end, and emits Event::ToolEnd after validate_arguments accepts the object. A string="false" value stays private while close_literal may still rewrite it, so no published byte is replaced, and the published fragments concatenate to exactly the stored arguments. Strict tools keep the existing parking path, so they still emit no frame before the compiled schema accepts their arguments.

A call announced before its arguments are complete must not fail the request when the generation is cut short. Accumulator::finish keeps its pre-PR &self shape and its error for an unfinished call at natural end-of-sequence; the drop of an announced but unfinished Chat call moves to discard_unfinished_call, which Encoder::finish calls under drops_unfinished_call(cause). On the Responses wire, ResponseOutput reports the block it closed for a truncated call through is_abandoned(index) while the encoder renders its closing frame, and discard_abandoned() removes it afterwards. An abandoned item reports status incomplete for every termination that drops it, not only for the output limit, and a custom tool call among them skips the JSON parse and grammar validation over arguments that never arrived and closes with an empty input instead of failing the request.

docs/api.md states which parsers publish fragments, what those fragments concatenate to, how a truncated call ends, and that a required or named tool choice still fails when omitting the call leaves no completed call. It scopes the fragment-identity claim to function calls, because a custom tool call publishes no fragment while the model writes and the text a client assembles is the item's input rather than the stored argument object.

Two contracts main guarantees change here, and both follow from publishing before the envelope closes: a non-EOS truncation omits the announced call where main raised incomplete emitted tool call, and streamed fragments are published before validate_arguments and before the 1 MiB parser bound that #364 introduced. @voipmonitor and @yatesdr, as #364's author and reviewer: do you accept the omission rather than the error for a non-EOS truncated call, and post-publication validation and size enforcement for streamed calls? If either answer is no, say which behavior you want and this pull request changes instead of leaving the rule reversed.

Clients receive the tool name as soon as the call opens and argument text as the model writes it, and it works against the served backend: a live request that previously returned two frames for a 2.2 KB write argument now returns 566. The fragments a client assembles equal the arguments of the completed call byte for byte, reasoning, content and tool-call ordering are unchanged, and a call cut off by an output limit, a stop string or a cancellation now ends as an incomplete item rather than a failed request. The Qwen function-tag, GLM argument-tag, MiniMax XML and Gemma call parsers still buffer because their arguments are synthesized from parameter syntax, so this pull request streams only the DSML dialect. A chat-completions request with stream: true, one write tool and tool_choice: "required" returned 566 argument frames totalling 2196 bytes, and their concatenation hashed identically to the same request's non-streaming arguments; the tagged dialects were not exercised against a served model.

Tests: helios/src/server/protocol/tests.rs drives a truncated custom call and a truncated function call on all three wire protocols and every termination cause, including the custom call's empty input, its missing input frames and the forced tool choice that must still fail, and it holds the truncation matrix as one table per property. In helios/src/output/dsml.rs the streaming tests assert the published prefix while an envelope is open, concatenation against the stored arguments at every UTF-8 split, a rewritten literal, end-of-sequence and schema rejection after fragments, and the folded truncation rows.

On this head, cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --no-fail-fast runs all fifteen targets and reports 1848 passed, 20 failed and 84 ignored. The same command at the branch point 1fbcc3c9 reports 1776 passed and 17 failed in the library plus the same 3 message_boundaries failures, so the twenty failures are older than this pull request and none of them touches the tool-call code: eleven engram tests fail against this host's 8 MiB RLIMIT_MEMLOCK (register Engram staging: Cannot allocate memory) and pass when run alone, and nine chat-template tests need FLARE_TEST_TEMPLATE_DIR from tests/frontend/prepare_templates.py. The deepseek_output and deepseek_requests integration suites pass 15 each. cargo build --locked --release --manifest-path flare/Cargo.toml and the same for flare-cli/Cargo.toml both succeed, and their suites report 254 and 245 passed with no failure. Two probes drive the review's symptoms directly: at the branch point a truncated custom call fails with custom tool input does not match its grammar and a UserStop truncation reports status completed; on this head both succeed with status incomplete.

Discord: peperunas

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 685.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. model:deepseek-v4.1 Affected recipe or documented reproducer: deepseek-v4.1. Impact may be broader. model:deepseek-v4 Affected recipe or documented reproducer: deepseek-v4. Impact may be broader. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@peperunas
peperunas force-pushed the fix/dsml-tool-call-streaming branch from 2f0ed9d to 80c87b3 Compare December 2, 2026 18:15
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core streaming mechanism in DsmlOutput (Call::publish with published_argument_bytes and literal deferral for string="false" values) is small, clean, and directly addresses the stalled-stream UX for multi-kilobyte DeepSeek tool calls while keeping strict-tool parking intact. However, this PR breaks four existing integration tests in helios/tests/ (skipped because only --lib was run), leaves already-announced Messages/Responses tool blocks permanently unclosed when a call is truncated, and reverses reviewed pre-publication and retraction invariants without maintainer sign-off.

  • Blockers: 2 · Should fix: 1 · Subtract/Simplify: 4 · Nits: 2
Walkthrough
  • Incremental DSML publication (helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): Moves Event::ToolBegin from ToolCallArgumentsEnd to ToolNameEnd, adds Call::published_argument_bytes and Call::publish to emit Event::ToolArguments fragments on each ToolCallArgumentsText action (while deferring string="false" values until close_literal settles them), and emits trailing bytes + Event::ToolEnd after validate_arguments.
  • Unfinished-call omission on non-EOS termination (helios/src/server/output.rs:163-173, 478-480, 1730-1742, helios/src/server/protocol/encode.rs:674-677): Adds drops_unfinished_call(cause) -> cause != Termination::Eos and threads cause into Accumulator::finish(cause) and ResponseOutput::finish(cause) to pop an open trailing tool call instead of returning Err("incomplete emitted tool call").
  • Mechanical test call-site updates (8 files): Updates output.finish() → output.finish(Termination::Eos) across argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, xtml.rs, runtime_core/protobuf.rs, and server/runtime/phase_tests.rs, and inverts user_stop_cannot_retract_an_already_emitted_partial_tool_call in helios/src/server/output.rs:1265-1274.
  • New unit tests & API docs (helios/src/output/dsml.rs:749-1033, helios/src/server/protocol/tests.rs:3809-4073, docs/api.md:540-575): Adds unit tests for DSML fragment prefix/concatenation, string="false" literal deferral, truncation, and Chat end-to-end streaming, and updates docs/api.md to document DSML streaming, non-EOS omission, and post-publication 1 MiB enforcement.
Merge Risk: High · up to 2f0ed9d
  • Guaranteed CI breakage in helios/tests/: Four existing integration tests in helios/tests/deepseek_output.rs and helios/tests/deepseek_requests.rs assert pre-streaming DSML behavior and will fail under .github/workflows/native-serving.yml:63 (not opened),68 (cargo test ... --features runtime-core,server without --lib).
  • Protocol-framing violation on streaming truncation: In helios/src/server/output.rs:1730-1742, popping an unfinished Block::Tool before close() causes Messages and Responses streams to emit message_delta/message_stop or response.incomplete/response.completed while a previously sent content_block_start or response.output_item.added remains open.
  • No runtime concurrency, memory, or TTFT regressions: All modified state (DsmlOutput, Accumulator, ResponseOutput, Encoder) is strictly per-request (helios/src/server/http.rs:451-600); Call::publish slices into the existing 1 MiB-bounded argument buffer (O(n) total allocation), and helios/src/server/latency.rs:116-142 (stream_text) excludes tool-call deltas so TTFT metrics are unaffected.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: No unsafe code, external I/O, or instruction-hijacking patterns; parser (1 MiB) and response (8 MiB) bounds remain enforced.
  • ⚠️ Charter & value fit: Streaming DSML arguments directly serves the charter's coding-agent/heavy-tool-use vision with no per-model shared-layer branch, but no issue/maintainer request exists and the PR reverses reviewed invariants (#364 pre-publication bound and user_stop_cannot_retract_an_already_emitted_partial_tool_call) without maintainer sign-off (AGENTS.md:182-187, 204-207).
  • ⚠️ Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with #670 (its docs/api.md edits start at line 586 and its dsml.rs edits are in grammar_envelope), but #670 added TAGGED_JSON after the branch point, making docs/api.md:543-547's characterization of all tagged parsers as parameter-syntax-based stale after rebase; #364's pre-publication 1 MiB bound is directly reversed.
  • ⚠️ Tests & verification evidence: No CI run on 2f0ed9d; author ran only cargo test ... --lib (skipping helios/tests/, where four existing integration tests fail) and did not build/test flare or flare-cli (docs/design-review.md:180-185).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@flare-autobot flare-autobot added bug Something isn't working enhancement New feature or request labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core streaming mechanism in DsmlOutput is minimal, byte-exact, and solves stalled streaming for large DeepSeek tool calls without per-model runtime branches or concurrency/TTFT regressions. But at 80c87b3 it breaks four existing helios/tests/ integration tests that CI runs unconditionally, violates SSE framing when an announced tool call is truncated, and reverses the reviewed Err("incomplete emitted tool call") contract without maintainer sign-off.

  • Blockers: 3 · Should fix: 2 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • Incremental DSML tool-call streaming (helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): Emits Event::ToolBegin at OutputAction::ToolNameEnd, tracks Call::published_argument_bytes and publishes Event::ToolArguments fragments after each ToolCallArgumentsText append (while withholding string="false" literals until close_literal settles them), and flushes remaining bytes plus Event::ToolEnd after validate_arguments at ToolCallArgumentsEnd.
  • Unfinished-call omission on non-EOS termination (helios/src/server/output.rs:163-173, 476-480, 1730-1742, helios/src/server/protocol/encode.rs:674-677): Adds drops_unfinished_call(cause) -> cause != Termination::Eos and threads cause into Accumulator::finish and ResponseOutput::finish to pop an open trailing tool call instead of returning Err("incomplete emitted tool call").
  • Mechanical test call-site churn and inverted retraction test (9 files): Updates output.finish() → output.finish(Termination::Eos) across helios/src/output/{argument_tags,chatml,gemma_call,minimax_xml,pipeline,xtml}.rs, helios/src/runtime_core/protobuf.rs, helios/src/server/runtime/phase_tests.rs, dsml.rs, and output.rs, and rewrites user_stop_cannot_retract_an_already_emitted_partial_tool_call into user_stop_omits_an_already_emitted_partial_tool_call (helios/src/server/output.rs:1265-1274).
  • New unit tests and API documentation (helios/src/output/dsml.rs:749-1033, helios/src/server/protocol/tests.rs:3809-4073, docs/api.md:540-574): Adds DSML streaming/truncation/rejection tests and Chat/Messages/Responses buffered truncation tests plus an end-to-end DSML→Chat wire test, and updates docs/api.md for DSML streaming, non-EOS omission, and post-publication 1 MiB enforcement.
Merge Risk: High · up to 80c87b3
  • Guaranteed Linux and Windows CI failure in helios/tests/: .github/workflows/native-serving.yml:63, 68 run the full helios test target without --lib; four existing integration tests in helios/tests/deepseek_output.rs and helios/tests/deepseek_requests.rs assert pre-streaming DSML behavior and will fail.
  • SSE protocol-framing violation on streaming truncation: ResponseOutput::finish (helios/src/server/output.rs:1730-1742) drops an open Block::Tool before close(), so Messages and Responses streams send message_stop / response.completed / response.incomplete while a previously announced content_block_start or response.output_item.added remains permanently unclosed and vanishes from response.output.
  • No runtime concurrency, memory amplification, or TTFT regressions: All modified state (DsmlOutput, Accumulator, ResponseOutput, Encoder) is strictly per-request (helios/src/server/http.rs:451-600), Call::publish slices only newly appended bytes within the 1 MiB buffer (O(n) total allocation), strict-tool parking (helios/src/server/protocol/encode.rs:585-624) still withholds all frames until schema validation passes, and stream_text (helios/src/server/latency.rs:116-142) excludes tool-call deltas so TTFT metrics are unaffected.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: No unsafe code, external I/O, or instruction-hijacking patterns; 1 MiB parser (dsml.rs:22, 42-47, 234-236) and 8 MiB response (output.rs:119-121, 1817-1819) bounds remain enforced.
  • ⚠️ Charter & value fit: Streaming DSML arguments directly serves the charter's coding-agent/heavy-tool-use vision with no per-model shared-layer branch, but no issue or maintainer request is linked, and the PR reverses reviewed error/pre-publication invariants (user_stop_cannot_retract_an_already_emitted_partial_tool_call and #364) without maintainer sign-off (AGENTS.md:182-187, 201-207).
  • ⚠️ Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with #670 (its docs/api.md edits begin at line 586 on main and its dsml.rs edits are in grammar_envelope), but #670 added TAGGED_JSON after the branch point, making docs/api.md:543-547 factually false against main.
  • ⚠️ Tests & verification evidence: Only cargo test ... --lib was run (missing the 4 failing integration tests in helios/tests/), 16 tests failed locally (6 missing FLARE_TEST_TEMPLATE_DIR, 10 parallel engram tests), and flare / flare-cli were not built or tested (docs/design-review.md:180-185).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@peperunas
peperunas force-pushed the fix/dsml-tool-call-streaming branch from 80c87b3 to b9864ab Compare December 2, 2026 21:47
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The incremental DSML streaming core (DsmlOutput::apply + Call::publish) is clean, byte-exact, and free of concurrency or TTFT regressions, and b9864ab fixes the four broken helios/tests/ integration tests and the Messages closing-frame order. However, the new Change::End-before-drop path regresses truncated Responses custom tool calls, and the PR still reverses reviewed pre-publication (#364) and non-EOS incomplete-call error contracts without maintainer sign-off.

  • Blockers: 2 · Should fix: 3 · Subtract/Simplify: 3 · Nits: 1
Walkthrough
  • Incremental DSML publication (helios/src/output/dsml.rs:38, 49-62, 145-156, 191-206): Emits Event::ToolBegin at ToolNameEnd, tracks Call::published_argument_bytes and publishes Event::ToolArguments fragments after each ToolCallArgumentsText append (keeping string="false" literals unpublished until close_literal settles them), and flushes remaining bytes plus Event::ToolEnd after validate_arguments at ToolCallArgumentsEnd.
  • 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): Adds drops_unfinished_call(cause) -> cause != Termination::Eos, passes cause into Accumulator::finish and ResponseOutput::finish, emits Change::End(last) for a truncated trailing tool block before drop_abandoned pops it, and omits it from the buffered body.
  • Mechanical test call-site updates (8 files) & inverted/updated tests: Threads Termination::Eos into output.finish(...) across argument_tags.rs, chatml.rs, gemma_call.rs, minimax_xml.rs, pipeline.rs, xtml.rs, runtime_core/protobuf.rs, and server/runtime/phase_tests.rs; rewrites user_stop_cannot_retract_an_already_emitted_partial_tool_call (helios/src/server/output.rs:1265-1274) and updates integration tests in helios/tests/deepseek_output.rs:499-515, 572-601 and helios/tests/deepseek_requests.rs:683-693 for 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 updates docs/api.md for DSML streaming, non-EOS omission, and post-publication 1 MiB enforcement.
Merge Risk: High · up to b9864ab
  • Direct regression on Responses custom tool truncation (streaming and buffered): Rendering Change::End for an abandoned tool block before drop_abandoned routes partial JSON arguments into Encoder::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 as incomplete/completed on main into response.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) replaces main's non-EOS Err("incomplete emitted tool call") with silent omission across all tool parsers and wire protocols, while DSML streaming publishes ToolBegin/ToolArguments prior to validate_arguments and #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::publish slices newly appended bytes within the 1 MiB buffer (with start >= published_argument_bytes preserved across close_literal), strict-tool parking (encode.rs:585-624) remains intact, and stream_text (helios/src/server/latency.rs:116-142) excludes tool-call deltas so TTFT sampling is unchanged.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ 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.
  • ⚠️ 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 #364 pre-publication and non-EOS error invariants without maintainer sign-off (AGENTS.md:182-187, 201-207).
  • ⚠️ Related / duplicate / conflict check: No duplicate PR and no textual merge conflict with #670 (its docs/api.md additions begin at line 610 on main), but #670 added TAGGED_JSON (helios/src/output/tagged_json.rs:14-49, 57 on main), making docs/api.md:543-547 factually false against main; #364's pre-publication 1 MiB guarantee is reversed.
  • ⚠️ Tests & verification evidence: No CI run on b9864ab; self-reported counts in the PR body were run with --lib only (omitting helios/tests/, which was edited in b9864ab and is run unconditionally by .github/workflows/native-serving.yml:63, 68), and flare / flare-cli were not built or tested (docs/design-review.md:180-185).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

A DeepSeek tool call now reaches the client as the model writes it: the call's name is announced when its header completes, and its argument text is published fragment by fragment instead of arriving whole when the invoke tag closes.

The pinned `deepseek-recipe` parser already releases each argument label and text fragment as it decodes input, but `DsmlOutput` collected them and emitted the begin, arguments and end events together at `ToolCallArgumentsEnd`. A client therefore received nothing between the tool name and the finished argument object: a multi-kilobyte `write` argument left the stream silent for the whole generation, which a client renders as a stalled response and an agent loop cannot tell apart from a hung model. The encoder and both block emitters already open a tool call on `Event::ToolBegin` and forward each `Event::ToolArguments` fragment, so the defect was confined to when the parser published them.

`DsmlOutput::apply` now emits `Event::ToolBegin` at `ToolNameEnd`, publishes the argument bytes appended by each argument-text action and the rest at `ToolCallArgumentsEnd`, so label bytes travel with the next text fragment or that end, and emits `Event::ToolEnd` after `validate_arguments` accepts the object. A `string="false"` value stays private while `close_literal` may still rewrite it, so no published byte is replaced, and the published fragments concatenate to exactly the stored arguments. Strict tools keep the existing parking path, so they still emit no frame before the compiled schema accepts their arguments.

A call announced before its arguments are complete must not fail the request when the generation is cut short. `Accumulator::finish` keeps its pre-PR `&self` shape and its error for an unfinished call at natural end-of-sequence; the drop of an announced but unfinished Chat call moves to `discard_unfinished_call`, which `Encoder::finish` calls under `drops_unfinished_call(cause)`. On the Responses wire, `ResponseOutput` reports the block it closed for a truncated call through `is_abandoned(index)` while the encoder renders its closing frame, and `discard_abandoned()` removes it afterwards. An abandoned item reports status `incomplete` for every termination that drops it, not only for the output limit, and a custom tool call among them skips the JSON parse and grammar validation over arguments that never arrived and closes with an empty input instead of failing the request. `docs/api.md` states which parsers publish fragments, what those fragments concatenate to, how a truncated call ends, and that a `required` or named tool choice still fails when omitting the call leaves no completed call.

Two contracts `main` guarantees change here, and both follow from publishing before the envelope closes: a non-EOS truncation omits the announced call where `main` raised `incomplete emitted tool call`, and streamed fragments are published before `validate_arguments` and before the 1 MiB parser bound that NVIDIA#364 introduced. @voipmonitor and @yatesdr, as NVIDIA#364's author and reviewer: do you accept the omission rather than the error for a non-EOS truncated call, and post-publication validation and size enforcement for streamed calls? If either answer is no, say which behavior you want and this pull request changes instead of leaving the rule reversed.

Clients receive the tool name as soon as the call opens and argument text as the model writes it, and it works against the served backend: a live request that previously returned two frames for a 2.2 KB `write` argument now returns 566. The fragments a client assembles equal the arguments of the completed call byte for byte, reasoning, content and tool-call ordering are unchanged, and a call cut off by an output limit, a stop string or a cancellation now ends as an incomplete item rather than a failed request. The Qwen function-tag, GLM argument-tag, MiniMax XML and Gemma call parsers still buffer because their arguments are synthesized from parameter syntax, so this pull request streams only the DSML dialect. A chat-completions request with `stream: true`, one `write` tool and `tool_choice: "required"` returned 566 argument frames totalling 2196 bytes, and their concatenation hashed identically to the same request's non-streaming arguments; the tagged dialects were not exercised against a served model.

Tests: `helios/src/server/protocol/tests.rs` drives a truncated custom call and a truncated function call on all three wire protocols and every termination cause, including the custom call's empty input, its missing input frames and the forced tool choice that must still fail, and it holds the truncation matrix as one table per property. In `helios/src/output/dsml.rs` the streaming tests assert the published prefix while an envelope is open, concatenation against the stored arguments at every UTF-8 split, a rewritten literal, end-of-sequence and schema rejection after fragments, and the folded truncation rows. On `75764de2`, `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --no-fail-fast` runs all fifteen targets and reports 1848 passed, 20 failed and 84 ignored, against 1846 passed and 21 failed for the same command at `b9864ab8`; all 20 failures exist at both heads, eleven of them engram tests that fail against this host's 8 MiB `RLIMIT_MEMLOCK` (`register Engram staging: Cannot allocate memory`) and pass when run alone, nine needing `FLARE_TEST_TEMPLATE_DIR` from `tests/frontend/prepare_templates.py`, and the `message_boundaries` suite failing the same 3 tests at both heads. The `deepseek_output` and `deepseek_requests` integration suites pass 15 each. `cargo build --locked --release --manifest-path flare/Cargo.toml` and the same for `flare-cli/Cargo.toml` both succeed, and their suites report 254 and 245 passed with no failure. Two probes drive the review's symptoms directly: at `b9864ab8` a truncated custom call fails with `custom tool input does not match its grammar` and a `UserStop` truncation reports status `completed`; at `75764de2` both succeed with status `incomplete`.

Design-Signed-Off-By: pi coding agent; design-review=2e5b
Signed-off-by: Giulio De Pasquale <git@depasquale.giugl.io>
@peperunas

Copy link
Copy Markdown
Author

@flare-autobot take another look please

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot declined to run because no new commits have been pushed since the last review. See the existing Case file — push new changes and mention @flare-autobot again when you are ready for another pass.

A custom tool call publishes no argument fragment while the model writes, and the
text a client assembles is the item's input rather than the stored argument
object, so the fragment-identity sentence held only for function calls.

Design-Signed-Off-By: pi coding agent; design-review=2e5b
Signed-off-by: Giulio De Pasquale <git@depasquale.giugl.io>
@peperunas

Copy link
Copy Markdown
Author

@flare-autobot the head now carries a new commit since your last pass (826a427): please take another look.

@flare-autobot flare-autobot added triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. and removed triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 5, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Commit 826a427 resolves every technical, protocol, documentation, and test-churn issue from Round 3 — truncated custom calls close as incomplete, abandoned function calls report status: "incomplete", docs/api.md is accurate, and the diff shrank from 15 files to 7. The sole remaining blocker is the unresolved Round 3 governance gate: this PR reverses two reviewed main invariants (#364's pre-publication 1 MiB/validation bound and the non-EOS incomplete emitted tool call error) and no maintainer decision is recorded on the PR yet, so once @voipmonitor/@yatesdr sign off in the thread no further code changes are required.

  • Blockers: 1 · Should fix: 0 · Subtract/Simplify: 3 · Nits: 2
Walkthrough
  • Incremental DSML publication (helios/src/output/dsml.rs:38, 49-62, 151-155, 191-205): Announces Event::ToolBegin at ToolNameEnd, tracks Call::published_argument_bytes and emits Event::ToolArguments fragments via Call::publish after each ToolCallArgumentsText append (keeping string="false" literals unpublished until close_literal settles them), and flushes trailing bytes plus Event::ToolEnd after validate_arguments.
  • Non-EOS unfinished-call omission without Accumulator::finish churn (helios/src/server/output.rs:163-174, 479-481, 1707, 1735-1762): Keeps Accumulator::finish(&self) unchanged from main, adds discard_unfinished_call(&mut self), adds drops_unfinished_call(cause) -> cause != Termination::Eos, and exposes ResponseOutput::is_abandoned(index) / discard_abandoned() so closing frames render before the truncated block is popped.
  • Abandoned-item and custom-tool handling in Encoder (helios/src/server/protocol/encode.rs:470-491, 511-514, 681-707): Calls discard_unfinished_call() on Chat and ResponseOutput::finish(cause) / discard_abandoned() on Messages/Responses, marks any abandoned Responses item as incomplete regardless of termination cause, skips JSON/grammar validation and custom_tool_call_input.* frames for abandoned custom calls (emitting input: ""), and clears incomplete_item after discarding.
  • Tests & API docs (helios/src/output/dsml.rs:750-1025, helios/src/server/protocol/tests.rs:56-87, 3844-4230, helios/tests/deepseek_{output,requests}.rs, docs/api.md:540-578): Adds folded truncation-matrix tests, truncated custom-tool and abandoned function-call tests, ToolChoice::Required | Named failure tests, UTF-8 split and literal-deferral tests, adapts deepseek_output.rs/deepseek_requests.rs for streaming events, and updates docs/api.md for DSML streaming, custom-tool scoping, non-EOS omission, required/named failures, and post-publication 1 MiB enforcement.
Merge Risk: Medium · up to 826a427
  • Unratified public-contract reversals: DsmlOutput::apply publishes Event::ToolBegin and argument fragments before validate_arguments and #364's 1 MiB bound (helios/src/output/dsml.rs:151-155, 191-205), and drops_unfinished_call omits announced-but-unfinished calls on UserStop / Cancelled / ExecutionError (helios/src/server/output.rs:479-481, 1735-1748; helios/src/server/protocol/encode.rs:681-707), reversing two reviewed main invariants (docs/api.md:580-583, 600 on main, helios/tests/deepseek_output.rs:511 on main, and user_stop_cannot_retract_an_already_emitted_partial_tool_call).
  • Prior protocol regressions and CI breakage resolved: Truncated Responses custom tool calls skip JSON/grammar validation and suppress response.custom_tool_call_input.{delta,done} (encode.rs:470-491, 511-514), abandoned Responses items report status: "incomplete" across all non-EOS causes (encode.rs:687-707), Messages/Responses closing frames are emitted before discard_abandoned(), and the helios/tests/ integration suites pass on the updated contract.
  • No concurrency, memory, or hot-path regressions: All modified state is per-request (helios/src/server/http.rs:358-400), Call::publish slices newly appended bytes within the 1 MiB buffer with published_argument_bytes <= literal_start preserved across close_literal, Encoder::apply feeds one event at a time to Accumulator::apply (O(total bytes) total work), strict-tool parking (encode.rs:592-631) is untouched, and Protocol::Responses is strictly single-choice (helios/src/server/protocol/decode.rs:835).
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ 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, 1837-1839) bounds remain enforced.
  • ⚠️ Charter & value fit: Directly serves the charter's coding-agent / heavy-tool-use vision with no per-model shared-layer branch and honest disclosure in the PR description, but reverses two reviewed main invariants (#364 pre-publication bound and non-EOS incomplete emitted tool call error) without the explicit maintainer sign-off required by AGENTS.md:182-187, 201-207.
  • ✅ Related / duplicate / conflict check: No duplicate PR; #670's TAGGED_JSON semantic mismatch in docs/api.md:540-547 is fixed, and any rebase over #670 is conflict-free; #364 reversal is disclosed and tracked in Blocker Congratulations! #1.
  • ✅ Tests & verification evidence: Full 15-target release helios test command (with 1fbcc3c9 baseline comparison explaining the 20 pre-existing environment failures), deepseek_output/deepseek_requests (15 passed each), flare (254 passed), flare-cli (245 passed), and live served parity probe are all reported on 826a427.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Only a Responses item carries a status: a truncated Messages block ends with
content_block_stop and reports the truncation through message_delta, and a Chat
call has no per-call closing frame.

Design-Signed-Off-By: pi coding agent; design-review=2e5b
Signed-off-by: Giulio De Pasquale <git@depasquale.giugl.io>
@peperunas

Copy link
Copy Markdown
Author

@yatesdr, @voipmonitor do you have feedback on this?

Design-Signed-Off-By: pi coding agent; design-review=2e5b
Signed-off-by: Giulio De Pasquale <git@depasquale.giugl.io>
@peperunas

Copy link
Copy Markdown
Author

Round 4's three simplifications and two nits are on the head, and every technical finding is closed: Call::publish now owns the size check, the Responses Change::End arm matches the block once, ResponseOutput::finish reads self.open, the parser-layer duplicate test carries a dsml_ prefix, the truncated-custom matrix covers all four causes, and docs/api.md scopes the closing-frame status to Responses.

One ordering detail follows from the first item: the 1 MiB check now runs inside publish, so a call that is both over the bound and invalid at ToolCallArgumentsEnd reports the validation error; the bound still fails before any byte of the crossing append is published.

@voipmonitor @yatesdr: the remaining blocker is your decision on the two main invariants this pull request reverses, both forced by publishing before the envelope closes. First, an announced call cut off by an output limit, a stop string or a cancellation is omitted from the buffered response, where main raised incomplete emitted tool call; Eos keeps the error. Second, argument fragments are published as the parser appends them, so validate_arguments and the 1 MiB bound follow publication instead of preceding it; strict tools still publish nothing before their schema accepts the arguments, and the published fragments concatenate to the stored arguments byte for byte. Do you accept both? If either answer is no, say which behavior you want and this pull request changes.

@flare-autobot the head carries the review's simplifications and two documentation commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. bug Something isn't working enhancement New feature or request model:deepseek-v4 Affected recipe or documented reproducer: deepseek-v4. Impact may be broader. model:deepseek-v4.1 Affected recipe or documented reproducer: deepseek-v4.1. Impact may be broader. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants