Skip to content

/v1/responses echo omits the request's tools and always reports text.format: text; tool outputs always decode with is_error: false #450

In review

Description

@shieldstar

Summary

Three behaviours of the Responses API surface do not follow the request that produced them.

  1. The response object always carries "tools": [] and "text": {"format": {"type": "text"}},
    even when the request declares tools and asks for a required tool call. The same object then
    reports "tool_choice": "required" next to the empty list.
  2. function_call_output and custom_tool_call_output input items always decode with
    is_error: false, whatever the item body says. The Chat path reads the field, so a Chat history
    replayed through Responses loses the failure flag.
  3. GET /v1/responses is answered with 400 and the message "WebSockets are not supported; use POST
    /v1/responses with HTTP/SSE".

Environment

  • Upstream commit: 25b49519cd3738b9d8509d7c59bd0e78c03c1a72
  • Build: cargo with --locked --offline, Linux arm64 (aarch64), rust 1.94.1
    (cargo test --features runtime-core,server --locked --offline --manifest-path helios/Cargo.toml --lib)
  • No GPU needed: the encoder, both decoder paths and the GET handler are driven directly

Steps to reproduce

From a clean checkout of the commit above:

  1. Add helios/src/server/protocol/qc_responses_echo.rs with the first module source below.
  2. Add helios/src/server/http_qc_responses_echo.rs with the second module source below.
  3. Register the first at the end of helios/src/server/protocol/mod.rs with:
#[cfg(test)]
#[path = "qc_responses_echo.rs"]
mod qc_responses_echo;
  1. Register the second at the end of helios/src/server/http.rs (inside mod http, so
    super::no_websocket is the exact function the router binds) with:
#[cfg(test)]
#[path = "http_qc_responses_echo.rs"]
mod qc_responses_echo_http;
  1. Run the four tests by full path:
cargo test --features runtime-core,server --locked --offline --manifest-path helios/Cargo.toml --lib \
  -- --exact server::protocol::qc_responses_echo::responses_object_reports_request_tools_and_text_format --nocapture
cargo test --features runtime-core,server --locked --offline --manifest-path helios/Cargo.toml --lib \
  -- --exact server::protocol::qc_responses_echo::function_call_output_decodes_with_is_error_false --nocapture
cargo test --features runtime-core,server --locked --offline --manifest-path helios/Cargo.toml --lib \
  -- --exact server::protocol::qc_responses_echo::chat_tool_result_is_error_is_honoured_control --nocapture
cargo test --features runtime-core,server --locked --offline --manifest-path helios/Cargo.toml --lib \
  -- --exact server::http::qc_responses_echo_http::get_v1_responses_is_rejected_with_400 --nocapture
step rc
cargo test … --lib -- --list (all four names present) 0
responses_object_reports_request_tools_and_text_format 0 (1 passed)
function_call_output_decodes_with_is_error_false 0 (1 passed)
chat_tool_result_is_error_is_honoured_control 0 (1 passed)
get_v1_responses_is_rejected_with_400 0 (1 passed)

helios/src/server/protocol/qc_responses_echo.rs:

use super::*;
use crate::server::inference::{Input, Part, Tool, ToolChoice};
use serde_json::json;

fn tools() -> Vec<Tool> {
    vec![Tool {
        name: "lookup".into(),
        namespace: None,
        description: "Find a value".into(),
        parameters: json!({"type":"object","properties":{"q":{"type":"string"}},"required":["q"]}),
        declared_parameters: true,
        custom: false,
        grammar: None,
    }]
}

fn encoder(protocol: Protocol, tool_choice: ToolChoice) -> Encoder {
    Encoder::new(
        protocol,
        "resp_echo".into(),
        "model".into(),
        1,
        1,
        vec![PromptUsage {
            tokens: 7,
            image_tokens: 0,
        }],
        tools(),
        tool_choice,
        true,
        false,
        json!(null),
    )
}

fn tool_result_flags(input: &Input) -> Vec<bool> {
    let mut flags = vec![];
    if let Input::Conversation(messages) = input {
        for message in messages {
            for part in &message.parts {
                if let Part::ToolResult { is_error, .. } = part {
                    flags.push(*is_error);
                }
            }
        }
    }
    flags
}

#[test]
fn responses_object_reports_request_tools_and_text_format() {
    let encoder = encoder(Protocol::Responses, ToolChoice::Required);
    let request_tools = tools().len();
    let response = encoder.response();
    eprintln!(
        "RESP responses_tools request_tools={request_tools} wire_tools={} wire_text={} wire_tool_choice={}",
        response["tools"], response["text"], response["tool_choice"]
    );
    assert_eq!(request_tools, 1);
    assert_eq!(response["tools"], json!([]));
    assert_eq!(response["text"], json!({"format":{"type":"text"}}));
    assert_eq!(response["tool_choice"], json!("required"));
}

#[test]
fn function_call_output_decodes_with_is_error_false() {
    let decoded = decode(
        Protocol::Responses,
        json!({"model":"m","input":[
            {"type":"function_call_output","call_id":"c1","output":"boom"},
            {"type":"custom_tool_call_output","call_id":"c2","output":"bang"}
        ]}),
        false,
    )
    .unwrap();
    let flags = tool_result_flags(&decoded.request.input);
    eprintln!("RESP responses_tool_result_is_error={flags:?}");
    assert_eq!(flags.len(), 2);
    assert!(flags.iter().all(|flag| !flag));
}

#[test]
fn chat_tool_result_is_error_is_honoured_control() {
    let decoded = decode(
        Protocol::Chat,
        json!({"model":"m","messages":[{"role":"tool","tool_call_id":"c","is_error":true,"content":"timeout"}]}),
        false,
    )
    .unwrap();
    let flags = tool_result_flags(&decoded.request.input);
    eprintln!("RESP chat_tool_result_is_error={flags:?}");
    assert_eq!(flags, vec![true]);
}

helios/src/server/http_qc_responses_echo.rs:

use axum::body::to_bytes;
use axum::http::StatusCode;

#[tokio::test]
async fn get_v1_responses_is_rejected_with_400() {
    let response = super::no_websocket().await;
    let status = response.status();
    let body = to_bytes(response.into_body(), 1 << 20).await.unwrap();
    let text = String::from_utf8_lossy(&body);
    eprintln!("RESP GET /v1/responses status={status} body={text}");
    assert_eq!(status, StatusCode::BAD_REQUEST);
    assert!(text.contains("WebSockets are not supported"));
}

Actual

test server::protocol::qc_responses_echo::responses_object_reports_request_tools_and_text_format ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1533 filtered out; finished in 0.00s
RESP responses_tools request_tools=1 wire_tools=[] wire_text={"format":{"type":"text"}} wire_tool_choice="required"

test server::protocol::qc_responses_echo::function_call_output_decodes_with_is_error_false ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1533 filtered out; finished in 0.00s
RESP responses_tool_result_is_error=[false, false]

test server::protocol::qc_responses_echo::chat_tool_result_is_error_is_honoured_control ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1533 filtered out; finished in 0.00s
RESP chat_tool_result_is_error=[true]

test server::http::qc_responses_echo_http::get_v1_responses_is_rejected_with_400 ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1533 filtered out; finished in 0.00s
RESP GET /v1/responses status=400 Bad Request body={"error":{"type":"invalid_request_error","message":"WebSockets are not supported; use POST /v1/responses with HTTP/SSE","param":null,"code":"invalid_request_error"}}

Expected

  • The response object should echo the tools the request sent, and a text format that reflects
    the request rather than a constant. Reporting "tool_choice": "required" together with
    "tools": [] is self-contradictory for a client reading the object back.
  • function_call_output and custom_tool_call_output should decode the same way the Chat path
    decodes a tool message, so replayed history keeps its is_error value (the Chat control returns
    true for the same field).
  • If GET /v1/responses is intentionally unsupported, the response and its message should be
    documented; today it advertises a POST/SSE endpoint in an error body a client cannot act on.

Source pointers

  • helios/src/server/protocol/encode.rs:692, in pub fn response(&self) (line 652), Responses arm
    literal: "tool_choice":tool_choice,"tools":[],"text":{"format":{"type":"text"}} — the tools
    array and text format are constants while self.tools is populated by Encoder::new
  • helios/src/server/protocol/decode.rs:311-318 — the
    "function_call_output" | "custom_tool_call_output" arm builds
    Part::ToolResult { …, is_error: false }; is_error is a literal at line 316 and the item body
    is not consulted
  • helios/src/server/protocol/decode.rs:170 and :227 — the Chat and Messages decoders read
    is_error from the payload, which is why the control sees true
  • helios/src/server.rs:533 — .route("/v1/responses", post(http::generate).get(http::no_websocket)…)
  • helios/src/server/http.rs:19-25 — no_websocket() returns BAD_REQUEST with
    "WebSockets are not supported; use POST /v1/responses with HTTP/SSE" (message at line 23)

Suggested fix

Emit the request's tools and text format in the Responses response object instead of the
constant [] / {"type":"text"} (the encoder already holds both). In the Responses output-item
arm, decode is_error from the item the way decode.rs:170 does for Chat, or document that
Responses tool outputs never carry the flag. For the GET route, either answer with a documented
capability error that names the supported method only, or drop the route.

Activity

  1. yatesdr commented on Nov 21, 2026

    @yatesdr
    Collaborator

    Checked at main 21a40f0:

    1. Confirmed. Every Responses object writes "tools":[] and "text":{"format":{"type":"text"}} (helios/src/server/protocol/encode.rs:692), while tool_choice is echoed from the request.
    2. Confirmed. function_call_output and custom_tool_call_output decode with is_error: false (helios/src/server/protocol/decode.rs:316), while Chat and Messages read the flag. The flag changes the rendered prompt, so a failed Responses tool result replays as a success.
    3. Documented. A GET on /v1/responses returns 400 because WebSocket transport is unsupported (docs/api.md, "WebSockets"); only the wording of the message is at issue.
  2. added
    bug
    area:api
    on Nov 21, 2026
  3. flare-autobot commented on Nov 30, 2026

    @flare-autobot
    Collaborator

    Confirmed all three behaviors on origin/main (c146d7be):

    1. Responses tools and text.format echo: Encoder::response() in helios/src/server/protocol/encode.rs:744-757 echoes tool_choice for Protocol::Responses while hardcoding "tools": [] and "text": {"format": {"type": "text"}} at line 756. In helios/src/server/protocol/decode.rs, decode() (lines 849-858) also concatenated Responses tool namespace descriptions directly into Tool.description and allowed duplicate namespace names, while options() (lines 509-528) dropped json_schema metadata (name, description, strict) when lowering body["text"]["format"].
    2. Responses tool-output is_error: responses_messages() in helios/src/server/protocol/decode.rs:337-345 constructed Part::ToolResult with literal is_error: false (line 343) for both function_call_output and custom_tool_call_output, unlike chat_messages() (decode.rs:191-198) and anthropic_messages() (decode.rs:250-255), dropping tool error signaling before inference::template_messages() (helios/src/server/inference.rs:359-363) and TmlV0 (helios/src/frontend/tml.rs:437-442).
    3. GET /v1/responses error text and documentation: helios/src/server.rs:585 routes GET /v1/responses to http::no_websocket() (helios/src/server/http.rs:19-25), which returns HTTP 400 with "WebSockets are not supported; use POST /v1/responses with HTTP/SSE", and docs/api.md did not document the GET /v1/responses 400 response.

    Implemented fix

    A fix is prepared on branch fix/issue-450-responses-echo-and-tool-error (commit f4143935), confined to Helios's shared HTTP protocol layer and docs/api.md (no changes to model contracts, cache schemes, scheduling, or CUDA graphs):

    • Responses tools echo and namespace preservation: Added namespace_description: Option<String> to inference::Tool (helios/src/server/inference.rs) with absent and empty descriptions normalized to None, rejected duplicate Responses namespace names with HTTP 400 in decode(), and moved nonempty namespace-description prepending into request::template_inputs() (helios/src/server/request.rs) before custom-tool grammar instructions. Encoder::response() now serializes tools via responses_tools() and responses_tool_entry() (echoing standalone function and custom tools with unqualified name, nullable parameters when undeclared, strict, text/Lark/regex custom formats, and first-appearance namespace grouping) across buffered JSON responses and all Responses SSE lifecycle events (response.created, response.in_progress, response.completed, response.incomplete, and response.failed).
    • Responses text.format validation and echo: Added single-pass responses_text_format() parsing in decode.rs for Protocol::Responses, validating text and text.format object types, object or boolean json_schema.schema values (matching helios/src/grammar.rs), and optional name, description, and strict fields, and checking mutual exclusion with top-level grammar before defaulting omitted or null text.format to {"type": "text"}. http::generate() passes Decoded.text_format into Encoder::set_text_format() before encoder.start().
    • Responses tool-output is_error parity: responses_messages() now decodes optional boolean is_error (omitted or null -> false, non-boolean -> HTTP 400) for both function_call_output and custom_tool_call_output, reusing shared Part::ToolResult lowering across Jinja, DeepseekV4, DeepseekV41, and TmlV0 prompt encoders (including multimodal input_text + input_image outputs).
    • GET /v1/responses response and docs: http::no_websocket() retains HTTP 400 (invalid_request_error) with "GET /v1/responses and WebSocket transport are not supported; use POST /v1/responses with HTTP JSON or SSE", and docs/api.md now documents the GET /v1/responses 400 response, Responses tools/text.format echoing, and Responses tool-output is_error support.

    Verification

    Executed on Linux aarch64 with external frontend templates prepared via tests/frontend/prepare_templates.py (FLARE_TEST_TEMPLATE_DIR):

    • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target: 1,805 passed, 0 failed, 83 pre-existing #[ignore] skipped. Includes 6 added tests covering decode -> encode -> decode tool/namespace round-trips and template_inputs parity, text.format validation and grammar mutual exclusion, text and multimodal is_error parity across all four prompt encoders, production http::generate buffered and SSE lifecycle echoing, and GET /v1/responses.
    • cargo test --locked --release --manifest-path flare/Cargo.toml --target-dir flare-cli/target: 245 passed, 0 failed, 4 pre-existing #[ignore] skipped.
    • cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 227 passed, 0 failed, 3 pre-existing #[ignore] skipped.

    Unrun checks: Live-service OpenAI Python SDK v2 contract tests (FLARE_API_TEST_URL=... .venv/bin/python -m pytest tests/server/test_protocols.py -q) and pre-existing #[ignore] GPU/checkpoint Rust tests were not run because no live native Flare server running an exported model core on NVIDIA GPU hardware was exercised.

    A pull request containing this fix is open at #638.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apibug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions