Recommendation: Ready To Merge
PR #638 cleanly resolves all three #450 defects in Helios's shared HTTP protocol layer and addresses every Round 1 finding (f414393 → 7ba8c66): responses_tools is now precomputed once in Encoder::new, Encoder::start() reuses a single built response, responses_text_format() is single-pass without .unwrap()/unreachable!(), {"type": "text"} is materialized in one place without non-Responses allocations, the TML test fixture is deduplicated, docs/api.md and the PR compatibility note are updated, and the branch is rebased onto 8da73911 (which includes #624 fixing the pre-existing Python CPU tests CI failure). No correctness, safety, concurrency, or regression defects remain; merge once CI (Native serving and Python CPU tests) is confirmed green on 7ba8c66.
Merge Risk
Level: Low
- Changes are strictly confined to Helios's shared HTTP protocol/request layer (
inference.rs,protocol/{mod,decode,encode,tests}.rs,request.rs,http.rs,runtime/phase_tests.rs) anddocs/api.md; no model-core, Protobuf, scheduler, prefix-cache layout, or CUDA-graph contracts are touched, and all workspaceTool/Decodedstruct literals are updated. - All added state (
responses_tools,text_format,namespace_description) is request-local, bounded bymax_body_bytes, dropped on request completion/disconnect, and never touched on per-token delta paths (Encoder::response()runs only on lifecycle envelopes). - The six added Rust CPU tests are isolated (no shared global state; temporary tokenizer files are thread/pid-scoped and deleted immediately) and exercise real production
decode,Encoder,request::template_inputs,Frontend::render_chatacross all four prompt encoders, andhttp::generate.
Walkthrough
- Namespace metadata & prompt lowering (
helios/src/server/inference.rs:60-61,helios/src/server/protocol/decode.rs:442,899-916,helios/src/server/request.rs:540-553): stores normalizednamespace_description: Option<String>onTool(absent/empty →None), rejects duplicate Responses namespace names with HTTP 400, omits empty namespace wrappers fromresponse.tools, and prepends nonempty namespace descriptions before custom-tool grammar instructions inrequest::template_inputs(). - Responses
text.formatvalidation (helios/src/server/protocol/mod.rs:67,helios/src/server/protocol/decode.rs:466-506,552-586,922,976,helios/src/server/http.rs:371): single-passresponses_text_format()validatestext,text.format,json_schema.schema(object or boolean, matchinghelios/src/grammar.rs:884-892), and optionalname/description/strictbefore admission, preservesgrammarmutual exclusion, and wiresDecoded.text_formatintoEncoder::set_text_format()beforeencoder.start(). - Responses
tools&text.formatechoing (helios/src/server/protocol/encode.rs:23-77,156-157,175-179,216-223,324-330,824-828): precomputesresponses_tools: Valueonce inEncoder::new()forProtocol::Responses(Value::Nullotherwise), reuses a single built response inEncoder::start(), and emits echoedtoolsandtext.format(materializing{"type": "text"}once whenNone) across buffered replies and all Responses SSE lifecycle events (response.created,response.in_progress,response.completed,response.incomplete,response.failed). - Responses tool-output
is_errorparity (helios/src/server/protocol/decode.rs:337-345): decodes optional booleanis_errorviaflag(&item, "is_error", false)?for bothfunction_call_outputandcustom_tool_call_output, matching Chat Completions and Anthropic Messages acrossJinja,DeepseekV4,DeepseekV41, andTmlV0(including multimodal outputs). GET /v1/responsesguidance, docs & tests (helios/src/server/http.rs:19-25,706-723,docs/api.md:230-233,579-582,747-752,helios/src/server/protocol/decode.rs:2092-2155,2277-2402,helios/src/server/protocol/tests.rs:3126-3807,helios/src/server/runtime/phase_tests.rs:4703-4942): updateshttp::no_websocket()error guidance for plain HTTPGET /v1/responsesand HTTP JSON/SSE, documents the GET 400, namespace, echo, andis_errorcontracts indocs/api.md, and adds six CPU/HTTP tests plus a sharedtml_frontend()helper.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or prompt-injection/directive content; per-request memory stays bounded by
max_body_bytes. - [PASS] Charter & value fit: Directly fixes maintainer-confirmed bug
#450, enforces the charter's "implement or reject, never silently ignore API fields" rule (#417), and stays model-agnostic in Helios's shared protocol layer. - [PASS] Related / duplicate / conflict check: Cleanly rebased onto
8da73911(#624,#637, and#626are already in the base with disjoint hunks); no superseding PRs. - [WARN] Tests & verification evidence: Six well-isolated Rust CPU tests pass locally (
1,816helios /245flare /227flare-cli), and rebasing onto#624addresses the priorPython CPU testsfailure, but CI status on7ba8c66is not directly visible here and live GPUtests/server/test_protocols.pycoverage was not run (disclosed); confirm green CI on7ba8c66before merging.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Reuse
crate::server::output::tests::frontendinprotocol/tests.rs(helios/src/server/protocol/tests.rs:3355-3404): The ~50-line inline BPE tokenizer / temp-file / SHA-256 /Frontend::load_with_settingsblock is used only to pass aPromptEncoder::Jinjafrontend intocrate::server::request::template_inputs()(:3405-3408). The existingpub(crate)helpercrate::server::output::tests::frontend(&["a", "b"])(helios/src/server/output.rs:504,516-561, already reused acrosslogprobs.rs(not opened) andstops.rs(not opened)) provides the same Jinja frontend in one line. (Optional cleanup.)
Nits
- Handler identifier (
helios/src/server/http.rs:19,helios/src/server.rs:585):no_websocketnow rejects plain HTTPGET /v1/responsesas well as WebSocket upgrades; optionally rename toget_responses_unsupported. - Live SDK test follow-up (
tests/server/test_protocols.py): In a follow-up when GPU serving tests run, consider adding assertions on echoedresponse.tools,response.text.format, and tool-outputis_errorvia the OpenAI Python SDK v2 client.
Dropped on verification
- Unexplained CI failure as a
7ba8c66Blocker (Dossier / Value Prop / Correctness): Dropped as a blocker — the prior red CI onf414393was on basec146d7bebefore#624(8da73911) fixed the permanently failingPython CPU testspremises;7ba8c66rebased onto8da73911with all Rust suites re-run and no code defects remaining. Confirming green CI on7ba8c66is kept as aPre-merge Checkswarning rather than blocking on nonexistent code changes. response.toolsvsresponse.tool_choicenamespaced mismatch as "Major" (Correctness #3.1): Dropped —docs/api.md:548-550specifiesnamespace__namefor named tool selection,decode.rs:855-860only readsname, and OpenAI'sToolChoiceFunctionhas nonamespacefield. The proposed fix ({"type":"function","name":"query","namespace":"db"}) would breakdecode(encode(decode(x)))round-tripping (protocol/tests.rs:3280-3324) and failRequest::validate()(inference.rs:193-197).- Silently ignoring
text.verbosity(Correctness #1.4): Dropped — pre-existing behavior onmain, out of scope for#450, and rejectingtext.verbosityunilaterally could break clients passing default verbosity fields. build_responses_tools()duplicatesdecode()/as_array_mut().unwrap()panic path (Subtraction #1): Dropped — carrying a pre-serialized tools array onDecodedwould add anotherEncodersetter and wiring inhttp.rsand breakEncoder's self-contained construction fromtools: Vec<Tool>;out[index]["tools"]is initialized as a JSON array 7 lines below (encode.rs:69), making.as_array_mut().unwrap()infallible, and an intermediate typed enum would add lines rather than subtract them.- Per-envelope copies of
responses_tools(Dossier §D.2, Correctness #2.2): Dropped — the upstream claim of "5 copies on post-start failure" is inaccurate (http.rs:576-578returns beforehttp.rs:582, so post-start failure performs 3 copies, not 5); Round 1'sHashMaprebuild is already removed,json!({"tools": ...})serializes into the outerValueregardless ofArc<Value>, and lifecycle-only copies are bounded bymax_body_bytesand never run per token delta. - Removing
.filter(|s| !s.is_empty())athelios/src/server/request.rs:543(Subtraction #2): Dropped (already dropped in Round 1) —Tool.namespace_descriptionis apubfield (inference.rs:61), so the 1-line filter defensively protects direct Rust callers. - Undocumented standard JSON type-validation 400s and semantic echo normalization in
docs/api.md(Dossier §C.3/§D.3, Correctness #3.2/#3.3): Dropped — Round 1 already dropped enumerating standard JSON type errors indocs/api.mdand the author added the requested namespace rules (docs/api.md:579-582) and PR compatibility disclosure. - Extracting a
generation_requesthelper forsendinhelios/src/server/runtime/phase_tests.rs:4767-4776(Subtraction #3b): Dropped as low-signal — the inline 6-line closure intentionally takes a customHttpStateand awaits inline (without spawning/blocking on the queue) to test pre-admission HTTP 400 rejection.