PR #638: Echo Responses tools and text.format and decode tool output is_error

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/4b14350c-02c6-4700-9e8c-629d0bc14f70

Opened by a workflow run, Nov 30, 2026 7:02 AM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: flare-autobot (COLLABORATOR account; git commit author is "derek"); Discord: flare-autobot Motivation: Helios's OpenAI Responses endpoint lies to clients about which tools and output format a request declared, and forgets the is_error flag on replayed tool failures, so SDK clients and agent loops see the wrong contract; this PR makes the endpoint echo what it was given and honour the error flag. Scale: +1316 / −33 lines in 9 files (+925 of that is tests; ~391 lines across 7 production/doc files) Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #638 "Echo Responses tools and text.format and decode tool output is_error"

1. Charter alignment — strong. Charter Goals include "Support the documented Chat Completions, Completions, Responses, and Messages APIs", and Standards target the documented OpenAI subset plus JSON Schema structured outputs. On main, Encoder::response() hardcoded "tools": [] and {"format":{"type":"text"}} (encode.rs:756 on main) and responses_messages() set is_error to a literal false (decode.rs:316) — the precise "accept it and quietly drop it" behaviour the charter forbids (#417). #638 implements those fields or rejects them, lives entirely in helios/src/server/protocol/* plus request.rs, adds no per-model branch (#267/#334), and touches no Non-Goal (no flags, aliases, deps, or defaults).

2. Novelty & status — genuinely additive. Nothing supersedes or reverts it. The echo defect has existed since the Responses endpoint landed (99cfcd5b, 2026-10-13, ~7 weeks), and #450 is open with maintainer triage (yatesdr: items 1–2 "Confirmed", item 3 "Documented"). Overlap with #548/#560 (encode.rs:818) and with #637 (protocol/tests.rs, docs/api.md) is textual rebase friction, not semantic conflict.

3. Value vs maintenance cost — real defect, thin demand, thin live evidence. Beneficiaries: clients deserializing Responses objects (SDKs, gateways, agent frameworks) and anyone replaying failed tool results through /v1/responses. The is_error lowering is verified to render identically to Chat and Messages across Jinja/DeepseekV4/DeepseekV41/TmlV0 — the strongest evidence in the PR. Against that: one reporter, two comments, nine days old; ~391 production+docs lines plus +925 test lines. No live-server or OpenAI Python SDK v2 evidence, and tests/server/test_protocols.py (which already asserts Responses tool shapes at :386-401) was not extended — declared, not hidden.

Gaps blocking merge:

Verdict: Worth it with changes. Charter-anchored, correctly layered, additive — but not mergeable until CI on the head is explained/green, the prompt-compatibility claim is corrected, and the new rejections plus echo semantics are documented.

(No instruction-like content was found in the reviewed material; "Discord: flare-autobot" is a signature, not a directive.)

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, priority:P2, bug, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +priority:P2, +bug, +area:api

Subtraction and simplicity

Subtraction/Simplicity/Conventions review of PR #638. Verdict: the production diff (~391 lines across 7 files) is lean — no flags, config knobs, env switches, per-model branches, fallback shims, or dead code. All six suggestions remove code; none adds abstraction.

  1. (High) options() re-matches text.format.type after responses_text_format() already validated it, behind .as_str().unwrap() and _ => unreachable!() — decode.rs:549-563 vs helper decode.rs:466-503. The PR body's "single-pass" claim is false. Fix: return (Option<Constraint>, Option<Value>) from the helper; deletes the second match, both unwraps, the panic path, and the has_format shadowing.
  2. (Med-High) Empty namespace-description normalization done three times, inconsistently: normalized at decode.rs:912-916, re-filtered at request.rs:520-527, then undone at encode.rs:320 (unwrap_or("")) while tool entries drop empty descriptions (encode.rs:50-52). Trust decode; delete both downstream guards.
  3. (Med) {"type":"text"} default written three times (decode.rs:562, decode.rs:584, encode.rs:187); the non-Responses value is built and discarded because Encoder::response() reads self.text_format only in the Responses arm (encode.rs:818). Make Decoded.text_format: Option<Value> and default once.
  4. (Med) The new prompt-parity test re-builds the TML frontend fixture (decode.rs:2263-2306) as a near-verbatim copy of decode.rs:2099-2157 — ~90 duplicated lines, though the module already has native/renderer helpers at decode.rs:1096-1100. Extract fn tml_frontend().
  5. (Low-Med) phase_tests.rs:4747-4755 is byte-identical to phase_tests.rs:59-67; hoist onto Fixture.
  6. (Low) http.rs:714-721 re-types the message constant from http.rs:23; assert type + .contains(...) instead.

Already lean: responses_tool_entry/responses_tools (encode.rs:23-54, 306-329), set_text_format following the existing setter pattern, and the is_error one-token substitution onto the existing flag() helper (decode.rs:343) are all right-sized.

Open questions: whether unreachable!() is acceptable at all; whether echoed namespace entries should carry description: ""; whether Option<Value> for text_format is welcome; whether decode.rs is meant to be the single fixture home.

Full report · Notes

Correctness and contracts

PR #638 is in the right layer and its core contracts hold (all five Responses lifecycle frames route through Encoder::response(), set_text_format runs before start(), is_error decoding matches Chat/Messages and is tested across four prompt encoders). Six issues survive scrutiny:

  1. Major — echo rebuilt and deep-cloned per call (encode.rs:294-300, 306-329, 42-46): start() alone builds response() twice and discards both for buffered requests (http.rs:626-641), so a Responses request serializes its whole tools array 3x (4x on failure), bounded only by max_body_bytes (32 MiB).
  2. Major — non-OpenAI wire type in response.tools (encode.rs:317-322): type:"namespace" entries are a Flare extension, and the only test that would catch SDK deserialization failure was neither run nor extended (tests/server/test_protocols.py untouched).
  3. Minor — unreachable!() panic path (decode.rs:552-556) guarded only by construction.
  4. Minor — residual self-contradictory metadata: grammar + omitted text.format echoes {"type":"text"} while generation is Lark-constrained (decode.rs:559-563, 586-591) — the same defect class #450 item 1 reported.
  5. Minor — seven new HTTP 400 conditions undocumented in docs/api.md.
  6. Minor — PR-body inaccuracy: prompts change for "description": "" namespaces (main prepended a bare "\n"); absent descriptions are unaffected (dossier correction).

Open questions: why is CI red on f414393 while the body reports 1,805/245/227 passing; whether the echo must be byte- or only semantically faithful.

Full report · Notes

Final review

Recommendation: Changes Requested

PR #638 cleanly fixes all three defects reported in #450 inside Helios's shared HTTP protocol layer with strong CPU unit, prompt-encoder, and http::generate lifecycle coverage. However, it should not merge until (1) the unexplained failing CI check on head f414393 is resolved and green, and (2) the per-request 4× redundant reconstruction and deep-cloning of responses_tools() across Encoder::response() calls is eliminated.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

  1. Unexplained CI failure on head f414393: The PR description reports 1,805 (helios), 245 (flare), and 227 (flare-cli) local passes with 0 failures on f414393, but CI failed on the same head commit and the failure is neither mentioned nor explained. Static inspection found no missing Tool/Decoded struct-literal updates across the workspace, so the exact failing CI job/log must be inspected and fixed (or re-run green) before merge to satisfy the repository's verification gate (docs/design-review.md Principle 12).

Should Fix

  1. Eliminate 4× redundant responses_tools() reconstruction and schema deep-cloning per Responses request (helios/src/server/protocol/encode.rs:294-300,306-329,730,818,827; helios/src/server/http.rs:415,534,582):
    • Verified behavior/impact: Encoder::response() now calls self.responses_tools(), which allocates a HashMap, rebuilds every tool/namespace JSON object, and deep-clones every tool's parameters JSON schema (encode.rs:42-46). In http::generate(), every successful /v1/responses request (both streaming and buffered) calls encoder.response() 4 times (and 3 times on post-start failure): twice back-to-back inside Encoder::start() (encode.rs:295 and :298, even though response was already computed on line 295), once in Encoder::finish() (encode.rs:730) or Encoder::failure() (encode.rs:827), and a fourth time at http.rs:582 (Delivery::Complete, which streaming discards at http.rs:614, while buffered discards the first three frames at http.rs:640). For coding-agent workloads declaring large JSON-schema tool lists (bounded only by 32 MiB max_body_bytes), this causes avoidable CPU and heap amplification on Tokio worker threads.
    • Fix: Since self.tools is immutable after Encoder::new, precompute responses_tools: Value once in Encoder::new when protocol == Protocol::Responses (and Value::Null otherwise) instead of calling self.responses_tools() on every response() call. Also reuse response.clone() in Encoder::start() (encode.rs:295-298) rather than calling self.response() twice.

Subtract / Simplify

  1. Make responses_text_format() truly single-pass and delete the .unwrap() / unreachable!() re-dispatch (helios/src/server/protocol/decode.rs:466-503,549-564): responses_text_format() already matches field(format, "type")? on "text" | "json_object" | "json_schema", then options() immediately re-matches format["type"].as_str().unwrap() with _ => unreachable!(). Return Result<Option<(Option<Constraint>, Value)>> (or Result<(Option<Constraint>, Option<Value>)>) from responses_text_format() directly, removing the second match, .unwrap(), unreachable!(), and extra format["schema"].clone() lookup.
  2. Collapse the three json!({"type": "text"}) defaults into one and avoid dead allocations on non-Responses requests (helios/src/server/protocol/mod.rs:67, decode.rs:562,584, encode.rs:187,818): Currently json!({"type": "text"}) is constructed in decode.rs:584 and again in Encoder::new (encode.rs:187) on every Chat, Completions, and Messages request even though self.text_format is read only in the Protocol::Responses arm (encode.rs:818). Store text_format: Option<Value> on Decoded and Encoder (defaulting to None), and materialize {"type": "text"} in a single place in Encoder::response().
  3. Deduplicate the ~58-line TML frontend fixture in decode.rs tests (helios/src/server/protocol/decode.rs:2263-2325 vs :2099-2157): Extract a shared fn tml_frontend(include_image_pad: bool) -> Frontend helper alongside native/renderer at decode.rs:1096 and call it from both tests.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (99%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with. decide malicious: all_clear (100%): No malicious content found

explore

Author: flare-autobot (COLLABORATOR bot account; the rebased head commit 7ba8c660 is authored by maintainer yatesdr); Discord: flare-autobot Motivation: On main, OpenAI-style Responses replies claimed there were no tools and no structured-output format even when the request declared them, ignored the is_error flag on failed tool results, and answered a plain GET /v1/responses with a WebSocket-only error. This PR makes the served response objects reflect the request and brings tool-error signalling in line with the Chat and Messages endpoints. Scale: +1305 / −51 in 9 files (head 7ba8c66; was +1316/−33 on the superseded f414393) Proposal:

Full report · Notes

Classify intake

Selected: triage:review, priority:P2, bug, area:api

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

No label changes

Value Proposition

Value Proposition — PR #638 (Echo Responses tools and text.format, decode tool-output is_error)

Charter alignment — strong. A shared-protocol-layer fix in Helios so POST /v1/responses echoes the tools and text.format it was given and decodes is_error on tool-output items. That enforces the charter's own rule: "either implement it according to the spec or reject it. Never accept it and quietly drop it (#417)." No per-model branch (#267/#334), no runtime growth, no non-goal touched (no new aliases, switches, hardware or model coverage). No performance claim, so the GPU-benchmark gate (#210) doesn't apply.

Novelty & status — genuinely additive. Fixes #450, which a maintainer triaged; the head commit 7ba8c660 is itself authored by a maintainer (per the dossier), though GitHub still lists flare-autobot as author with 0 human reviews. Not obsolete: the hardcoded "tools": [], {"type":"text"} and is_error: false were still on base 8da73911. Not superseded: #637 is already in the base with disjoint hunks on protocol/tests.rs and docs/api.md, so the predicted rebase conflict dissolved. Labels (area:api, bug, priority:P2, triage:review) confirm the project treats it as in scope.

Value vs maintenance cost — favourable. Beneficiaries are exactly the OpenAI-SDK clients the vision names: those reading response.tools/response.text to confirm active tools and structured-output constraints, and signalling failed tool calls via is_error. Evidence is Rust CPU tests only — five new tests (protocol/tests.rs:3126, :3476, :3677; decode.rs:2277; runtime/phase_tests.rs:4703) plus local 1,816/245/227 pass counts. Residual costs are small: the served-SDK contract is "expected but unmeasured" (tests/server/test_protocols.py untouched), and the tools array is deep-copied per lifecycle envelope (encode.rs:828; four copies per request, five on post-start failure) — cheap, since the per-response rebuild was already removed at 7ba8c66.

Required before merge:

  1. A CI result for 7ba8c66; the earlier red run on f414393 was never explained, and local-only counts aren't CI.
  2. Document the text.format validation 400s (non-object text/text.format, invalid json_schema.schema, invalid name/description, non-boolean strict, grammar-vs-format exclusion) beside docs/api.md:747-752, note that strict is always echoed and empty tool descriptions are dropped, and note the disclosed empty-namespace prompt-lowering change.
  3. Ideally add response.tools/text.format/is_error assertions on the served-SDK path, since that contract is the point of the change.

Verdict: Worth it with changes.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Subtraction and simplicity

Subtraction/simplicity review of PR #638 @ 7ba8c66: the diff is largely lean — the rework already removed the earlier bloat (single-pass responses_text_format(), one-shot build_responses_tools(), single {"type":"text"}, shared tml_frontend()), and no new knobs, flags, env-selected behaviour or dead code. Four simplifications remain:

  1. build_responses_tools() (encode.rs:55-77) re-derives namespace grouping decode already did (decode.rs:899-921) and its Value-indexed accumulation forces out[index]["tools"].as_array_mut().unwrap(); build the echo array in decode's existing loop and carry it on Decoded beside text_format (protocol/mod.rs:67), which also deletes the Value::Null branch at encode.rs:175-179.
  2. request.rs:540-547 re-filters .filter(|s| !s.is_empty()) although decode.rs:910 already normalises empty→None; drop it (8 lines → 5) so one layer owns the rule.
  3. Test duplication: protocol/tests.rs:3355-3404 hand-builds tokenizer/temp files that pub(crate) output::tests::frontend() (output.rs:516, reused at logprobs.rs:233 (not opened)/268/297/378/467/555/648) already provides; phase_tests.rs:4767-4776 copies the request-building tail of http_generation_request_observed (phase_tests.rs:4438-4467).
  4. no_websocket() (http.rs:19-25) now covers plain HTTP GET but keeps a WebSocket-only name; rename to get_responses_unsupported at http.rs:19 and its route.

Deliberately not raised: one-caller set_text_format (matches existing setter convention), the (has_format, text_format) tuple (needed for grammar exclusion on non-Responses), the Value::Null sentinel, and named-tool_choice flattening (pre-existing base behaviour).

Open questions: any CI result for 7ba8c66 (none found; evidence is local CPU runs only, no Python suite), whether the text.format 400s belong in docs/api.md:747-752, and whether tests/server/test_protocols.py (not opened) should assert response.tools/text.format/is_error. No human review exists; labels are area:api, bug, priority:P2, triage:review.

Full report · Notes

Correctness and contracts

Reviewed PR #638 at head 7ba8c66 (echo Responses tools/text.format, decode is_error, GET /v1/responses 400). The core fix is sound and well-placed; four issues remain.

Findings (most important first):

  1. Major, contract self-inconsistency: the new response.tools echo emits namespaced tools unflattened ({"type":"namespace","name":"db","tools":[{"name":"query"}]}, encode.rs:39-70), but response.tool_choice for a named pick still echoes the flattened db__query (encode.rs:819-822, forced by decode.rs:855-860 and native_name at inference.rs:84-89). A response object can name a tool absent from its own tools; the new test bakes in the flattened form (tests.rs:3279-3282). Caveat: flattened naming is pre-existing and documented (docs/api.md:548-550), so #638 exposes rather than introduces it — fixable in a few lines or gradable Minor.
  2. Minor, charter #417: text.verbosity is accepted and silently dropped — responses_text_format() validates only format (decode.rs:466-506) and no reject() list mentions verbosity (decode.rs:782-806); nothing in helios/src reads it. Fix: reject or echo it.
  3. Minor, docs: the new text.format/is_error HTTP 400 rejections and the empty-namespace prompt-rendering change are absent from docs/api.md (only the happy-path echo at :747-752 is documented).
  4. Minor, allocations: 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, never per token delta, no locks or I/O — avoidable, not a blocker.
  5. Major for evidence: all five new tests are Rust CPU only; tests/server/test_protocols.py asserts nothing about response.tools/text.format/is_error, so the headline served-SDK claim is unmeasured (the body admits it), and there is no CI result for this head.

Sound, no finding: is_error decoding is exact parity with Chat (decode.rs:197) and Messages (:254); duplicate-namespace 400 and empty-wrapper omission are correct (decode.rs:900-916); no protobuf/core/per-model/flag/scheduler/admission change; no concurrency or failure-propagation shift.

Open questions: is the prior red CI satisfied by the #624 rebase alone; de-flatten tool_choice now or defer; document the new rejections before merge; add served-SDK assertions.

Full report · Notes