#1 [high] Finding: tool_choice echo uses flattened namespace__name but tools echo is unflattened
PR #638, head 7ba8c66.
Encoder::response() Responses arm builds tool_choice from ToolChoice::Named(name):
encode.rs:815-823
let tool_choice = match &self.tool_choice {
ToolChoice::Auto => json!("auto"),
ToolChoice::None => json!("none"),
ToolChoice::Required => json!("required"),
ToolChoice::Named(name) => json!({
"type": if self.tool(name).is_some_and(|tool| tool.custom) { "custom" } else { "function" },
"name": name,
}),
};
name here is always the flattened form, because decode stores it verbatim (decode.rs:855-860 ToolChoice::Named(field(v, "name")?.into())) and inference::Request::validate (inference.rs:193-197) requires it to equal Tool::native_name() = namespace__name (inference.rs:84-89). docs/api.md:548-550 states this: "namespaced tools use namespace__name".
Meanwhile the new tools echo (responses_tool_entry encode.rs:33-48 + build_responses_tools encode.rs:65-70) emits the unqualified tool.name inside a {"type":"namespace","name":ns,...} wrapper. So for a namespaced tool the echoed response is self-contradictory:
response.tools = [{"type":"namespace","name":"db","tools":[{"type":"function","name":"query",...}]}]
response.tool_choice = {"type":"function","name":"db__query"} — a name that appears nowhere in response.tools.
The PR's own test bakes this in: tests.rs:3279-3282
(
json!({"type": "function", "name": "db__query"}),
json!({"type": "function", "name": "db__query"}),
),
i.e. it asserts the echo is byte-identical to the flattened input, and it round-trips because decode re-flattens. Only a scheme-aware/validating client sees the contradiction.
Severity: Major (contract). Impact: any client that validates tool_choice against the declared tools of the returned response object (the stated purpose of this PR: clients "read tools ... to confirm active tool declarations") cannot resolve db__query; OpenAI-shaped {"type":"function","name":"query"} with a namespace field is not what is emitted either. Before #638 tools was [] so there was nothing to compare against; the PR fixes half of the pair and leaves the other half inconsistent, and documents neither.
Fix: in the ToolChoice::Named echo arm, look up the tool and emit the namespaced shape ({"type":"function","name":"query","namespace":"db"} / {"type":"custom","name":...,"namespace":...}) when tool.namespace.is_some(); add a test that response.tool_choice names resolve to an entry in response.tools; document the rule in docs/api.md next to :747-752.
#5 [high] Test coverage/claim accuracy: SDK path untested, no CI
PR #638 head 7ba8c66. Untested/unverified paths I confirmed by opening the code:
responses_text_format()(decode.rs:466-506) is only wired inoptions()forProtocol::Responses(decode.rs:552-558). Other protocols still readresponse_format/output_config.formatwith the old loose path (decode.rs:560-579), so the new strict schema validation is not applied to Chatresponse_format.json_schema— asymmetric but intentional (out of scope), not a regression.Decoded.text_format(mod.rs:61-67) is only consumed by http.rs:371encoder.set_text_format(decoded.text_format). Two other production decode entry points never call it:request::prepare_inner(request.rs:49, in-process SDK path) anddecisions/mod.rs:752— both Chat only, sotext_formatis correctlyNone. No dead state.- Tests added are Rust CPU only: tests.rs:3126, :3476, :3677; decode.rs:2277; http.rs:706-720; phase_tests.rs:4703.
tests/server/test_protocols.py(972 lines, the served-SDK suite) still asserts nothing aboutresponse.tools,response.text.format, oris_error— grep hits at :543-571 only pass tools in requests. So the PR's central claim ("clients readtools/text.formatfrom returned response objects", "OpenAI Python SDK v2 Pydantic deserialization ... expected but unmeasured") has zero served-path coverage, and the PR body admits it. That is the main test gap; recommend adding one assertion in test_protocols.py that a Responses call with tools + text.format echoes them back and thatfunction_call_output.is_error=truerenders the error tokens. - No CI result for head 7ba8c66 exists in the PR; evidence offered is local aarch64 CPU runs (1,816 helios / 245 flare / 227 flare-cli) — no Python suite among them.
#6 [high] Research summary
I reviewed PR #638 at head 7ba8c66 across the four lens areas, opening every changed file plus its callers (http.rs generate path, server.rs router/admission, request.rs template lowering, grammar.rs schema validation, encode.rs lifecycle emitters, docs/api.md) and all five new tests.
Main finding (Major, contract): the PR makes response.tools echo namespaced tools in an unflattened {"type":"namespace","name":"db","tools":[{"name":"query"}]} shape (encode.rs:33-70) while response.tool_choice for a named pick still echoes the flattened db__query (encode.rs:815-823, forced by decode.rs:855-860 and Tool::native_name), so a response object can name a tool that does not appear in its own tools array — precisely the cross-field consistency this PR exists to establish. Its own test (tests.rs:3279-3282) asserts the flattened form.
Second finding (Minor→Major, charter #417): text.verbosity is accepted and silently dropped by the new responses_text_format() (decode.rs:466-506) and never rejected anywhere in decode(), and it is not echoed, so the response reports a text config the request didn't make.
Third (Minor): responses_tools is deep-copied ~4–5 times per request by the json! literal at encode.rs:828 (start+clone, completed/incomplete, failed, buffered Complete) — bounded by max_body_bytes (32 MiB default), off the per-token path, no contention; avoidable but not a blocker.
Test/claim accuracy: all new coverage is Rust CPU; tests/server/test_protocols.py still asserts nothing about response.tools/text.format/is_error, so the PR's headline served-SDK claim is unmeasured (the body admits it), and there is no CI result for this head. Minor docs gap: the disclosed prompt-rendering change for empty namespace descriptions is absent from docs/api.md.
Everything else checked out: is_error decoding matches Chat and Messages exactly, no protobuf/core/per-model/flag changes, get route and admission interaction unchanged, and the change is a good charter fit.
#7 [high] Verbatim code quotes for the report
PR #638 head 7ba8c66 — verbatim evidence for each finding.
FINDING 1 — tool_choice echo vs tools echo (Major). helios/src/server/protocol/encode.rs:815-823
let tool_choice = match &self.tool_choice {
ToolChoice::Auto => json!("auto"),
ToolChoice::None => json!("none"),
ToolChoice::Required => json!("required"),
ToolChoice::Named(name) => json!({
"type": if self.tool(name).is_some_and(|tool| tool.custom) { "custom" } else { "function" },
"name": name,
}),
};
helios/src/server/protocol/encode.rs:60-70 (tools echo, unqualified name inside namespace wrapper)
if let Some(ns) = tool.namespace.as_deref() {
if let Some(&index) = namespaces.get(ns) {
out[index]["tools"].as_array_mut().unwrap().push(entry);
} else {
namespaces.insert(ns, out.len());
out.push(json!({
"type": "namespace",
"name": ns,
"description": tool.namespace_description.as_deref().unwrap_or(""),
"tools": [entry],
}));
encode.rs:39-42 shows the entry carries "name": tool.name (unqualified):
json!({
"type": "function",
"name": tool.name,
Name is forced flattened: inference.rs:193-197 if let ToolChoice::Named(name) = &self.tool_choice { if !names.contains(name) { against names.insert(tool.native_name()) (inference.rs:177), and inference.rs:84-89 format!("{ns}__{}", self.name). Docs state the rule at docs/api.md:548-550 "namespaced tools use namespace__name". PR test bakes in the mismatch: tests.rs:3279-3282
(
json!({"type": "function", "name": "db__query"}),
json!({"type": "function", "name": "db__query"}),
),
Fix: emit namespaced shape from the Named arm when tool.namespace.is_some(); add a test asserting every response.tool_choice name resolves inside response.tools; document at docs/api.md:747-752.
FINDING 2 — text.verbosity silently dropped (Minor, #417).
decode.rs:466-506 validates only text/text.format/type/schema/name/description/strict; nothing reads verbosity (repo-wide verbosity hits: docs/clients/codex-models.json:16-17 "support_verbosity": false, and two unittest argv lines). decode.rs:782-806 rejection lists do not include verbosity:
reject(
&body,
&[
"previous_response_id",
"conversation",
"background",
"store",
],
)?;
Echo is rebuilt from scratch at decode.rs:482 so any verbosity is absent from the reply: "text" => Ok(Some((None, json!({"type": "text"})))),.
FINDING 3 — copies (Minor). encode.rs:824-828
let text_format = self
.text_format
.clone()
.unwrap_or_else(|| json!({"type": "text"}));
json!({... "tools":self.responses_tools,"text":{"format":text_format}})
Call sites: encode.rs:325-328 (start, then .clone() again), encode.rs:736 (finish), encode.rs:837 (failure), http.rs:582 (Delivery::Complete). Bound: server.rs:141 max_body_bytes: 32 * 1024 * 1024, capped at server.rs:276 config.max_body_bytes > 256 * 1024 * 1024.
TESTS/GAPS. New tests: tests.rs:3126, :3476, :3677; decode.rs:2277; http.rs:706-720 get_responses_returns_bad_request_with_http_json_and_sse_guidance; phase_tests.rs:4703 responses_http_generate_echoes_tools_and_text_format_across_lifecycle. tests/server/test_protocols.py has no response.tools/text.format/is_error assertion; PR body: "Expected but unmeasured against a live server". No CI result for the head anywhere in the PR.
SOUND AREAS. is_error parity: decode.rs:343 is_error: flag(&item, "is_error", false)? vs Chat decode.rs:197 flag(v, "is_error", false)? || failed and Messages decode.rs:254 — same helper (decode.rs:31-37, non-boolean → error). Duplicate namespace rejection decode.rs:900-906. Empty namespace wrapper → zero tools, "tools":[] echo (tests.rs:3427-3448). No proto/core/per-model/flag changes; route unchanged (server.rs:585); admit_http 503/429 precedence over the GET 400 is pre-existing.
#2 [medium] Finding: text.verbosity silently dropped (charter #417)
PR #638 head 7ba8c66. Two handshake fields are echoed without validation once text becomes an object.
Rust: decode.rs:466-506 responses_text_format() validates text.format.type, json_schema.schema, name, description, strict — but never inspects the sibling text.verbosity, and there is no reject(&body, ...) for it anywhere in decode() (rejections at decode.rs:783-786 and :787-806 list logit_bias/guided_json/previous_response_id/conversation/background/store, none for verbosity). The charter rule (AGENTS/README "Don't silently ignore API fields … implement it according to the spec or reject it. Never accept it and quietly drop it (#417)") applies directly.
Impact of ignoring it: text_format echo is {"type": ...} rebuilt from scratch (decode.rs:482-502), so {"text":{"verbosity":"low"}} is accepted, silently dropped from the prompt (nothing reads it — search_code verbosity finds no helios/src hit), and echoed as "text":{"format":{"type":"text"}} with no verbosity, i.e. the response claims a text config the request did not make. Same class of silent drop the PR is fixing for tools/format.
Severity: Minor (docs/contract) to Major if a client relies on it. Concrete fix: either reject text.verbosity with unsupported(...) or echo the accepted values. Test: add a case to tests.rs:3595-3641 alongside the other text rejections.
Also worth noting: tool_choice on Responses accepts an object {"type":"function","name":...} only via decode.rs:855-860; because the echo path is now exercised by the new tests, a client echoing the whole response object back as a new request (a documented usage for previous_response_id-less stateless replay) will pass tool_choice: {"type":"function","name":"db__query"} while tools contains a namespace wrapper — accepted, so replay works, but only because decode flattens. Not a bug, context for finding 1.
#3 [medium] System-level check: responses_tools copies bounded, no contention
PR #638 head 7ba8c66. Verified sound, no finding: per-request memory/copy cost.
responses_toolscomputed once inEncoder::new(encode.rs:175-179), stored asValue(encode.rs:156/216).response()embeds"tools": self.responses_tools(encode.rs:828) and clonestext_format(encode.rs:824-827). Because this sits inside ajson!literal,serde_json::to_value(&expr)deep-copies the whole tool array on every call. Call sites for Responses: encode.rs:325 (start, then cloned again at :327-328), :736 (finish), :837 (failure), plus http.rs:582 (Delivery::Complete). So ~4 deep copies of the tool array per successful request, 5 on late failure.- Bound: body limit
max_body_bytesdefault 32 MiB (server.rs:141) and ≤256 MiB (server.rs:276), so worst case is tens of MB per in-flight request, only on lifecycle envelopes, never per token delta. Not a hot path:response()is not called per SSE delta (chunk()/item()are). No lock contention, no I/O, no shared state touched. - Conclusion: correct but avoidable copies — a
&Value/Arc<Value>reuse or emittingValue::Nulland patching once would remove them. Minor/perf-only, not a blocker.
#4 [medium] Contract scan: disclosed prompt change, docs gap, is_error parity correct
PR #638 head 7ba8c66.
Base contract change: bench tool() for empty description used to prepend the namespace description unconditionally (main: t.description = format!("{description}\n{}", t.description) for any string description, including ""). Now decode.rs:907-911 normalizes empty/absent to None, and request.rs:540-547 prepends only when non-empty. Net effect: an explicit "description": "" no longer emits a leading "\n" before the tool description in the rendered prompt.
- Disclosed in the PR body ("explicitly empty
\"description\": \"\"namespace wrappers intentionally stop prependingmain's spurious leading\"\\n\""). - docs/api.md documents the namespace echo rules (:579-582) and echo of tools/text.format (:747-752) but says nothing about prompt rendering of namespace descriptions (only :584-586 covers the grammar instruction text). Diligence: a docs gap, Minor.
- Prefix-cache impact is one-time per client conversation, not per token; no cache-invalidations invariant reversed.
- Nonempty namespace descriptions still render identically (
{desc}\n{description}), asserted at tests.rs:3419-3425.
Other in-repo contracts checked and unchanged: no protobuf/core format edit (only helios/src/server/*, docs), no per-model branch added (all logic in the shared protocol layer + request::template_inputs), no new flag/env var, no scheduler/cache/CUDA-graph code touched. Charter fit is strong (fixes a #417-style silent-drop: tools hardcoded [], text.format hardcoded {"type":"text"}, is_error hardcoded false).
is_error decode (decode.rs:343 flag(&item, "is_error", false)?) matches Chat (decode.rs:197) and Messages (decode.rs:254); non-boolean → 400 like the others. Correct.
GET /v1/responses → 400 (http.rs:19-25, route server.rs:585) is still routed through admit_http, so an unhealthy model returns 503 and a full admission queue returns 429 before the 400 — pre-existing, unchanged by this PR, no finding.