[bug] Relay streaming intercept preserves buffered upstream stream flag

オープン
#1,367 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@deepujain がすでに取り組んでいます。

2026年11月21日 から。

  • #1370 @deepujain による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
rust
領域
api

調査の方向性

The bug is in decode_request in crates/switchyard-nemo-relay-plugin/src/runtime.rs, where the normalized llm_request.stream is set for streaming intercepts but raw_request keeps the caller's original stream value. Start there, then read the regression test stream_intercept_overrides_preserved_wire_flag in the same file's test module. Done when cargo test -p switchyard-nemo-relay-plugin stream_intercept_overrides_preserved_wire_flag --locked passes for the omitted, false and true caller variants. Linked PR #1370 is already open against this issue.

索引モデルが issue の本文から書いたものです。

説明

Symptom

A NeMo Relay streaming intercept can send a buffered request to an OpenAI-compatible target when the original wire body omits stream or sets it to false. This prevents incremental upstream content delivery on that path.

SwitchyardRuntime::decode_request(..., streaming = true) changes the normalized llm_request.stream, but retains the original body in raw_request. Same-format request preservation can therefore keep the original wire-level delivery mode.

Reproduction

Reproduced against main at 1cdbac59c780197e852f7b9cac1837fa1b2132d0.

  1. Use the Relay plugin's existing runtime_for_target("openai_chat", ...) test helper. It configures switchyard/default as a passthrough route to target/model.
  2. Pass an OpenAI Chat request to decode_request(WireFormat::OpenAiChat, request, true):
{"model":"switchyard/default","messages":[{"role":"user","content":"hello"}]}
  1. Execute it with execute_stream. A loopback mock expecting the outgoing body to contain "stream": true is not matched.

Add this regression inside the existing runtime.rs test module. It uses existing helpers and imports, and needs no provider credential:

    #[tokio::test]
    async fn stream_intercept_overrides_preserved_wire_flag() {
        for flag in [None, Some(false), Some(true)] {
            let server = MockServer::start().await;
            let sse = concat!(
                "data: {\"id\":\"test\",\"object\":\"chat.completion.chunk\",\"model\":\"target/model\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"hello\"},\"finish_reason\":null}]}\n\n",
                "data: {\"id\":\"test\",\"object\":\"chat.completion.chunk\",\"model\":\"target/model\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\n",
                "data: [DONE]\n\n",
            );
            Mock::given(method("POST"))
                .and(path("/v1/chat/completions"))
                .and(body_partial_json(
                    json!({"model": "target/model", "stream": true}),
                ))
                .respond_with(ResponseTemplate::new(200).set_body_raw(sse, "text/event-stream"))
                .expect(1)
                .mount(&server)
                .await;
            let runtime = runtime_for_target("openai_chat", &format!("{}/v1", server.uri()));
            let mut content = json!({"model": "switchyard/default", "messages": [{"role": "user", "content": "hello"}]});
            if let Some(flag) = flag {
                content["stream"] = json!(flag);
            }
            let request = runtime
                .decode_request(
                    WireFormat::OpenAiChat,
                    RelayRequest {
                        headers: Map::new(),
                        content,
                    },
                    true,
                )
                .unwrap();
            let stream = runtime.execute_stream(WireFormat::OpenAiChat, request, Arc::new(|_| {})).await.result.expect("stream intercept must request a stream even when its caller omitted the wire flag");
            let events = stream
                .collect::<Vec<_>>()
                .await
                .into_iter()
                .collect::<Result<Vec<_>, _>>()
                .unwrap();
            assert!(
                events
                    .iter()
                    .any(|event| event["choices"][0]["delta"]["content"] == "hello")
            );
        }
    }

Run:

cargo test -p switchyard-nemo-relay-plugin stream_intercept_overrides_preserved_wire_flag --locked

Expected vs. actual

  • Expected: the streaming intercept's outgoing request contains "stream": true, including when the caller omitted the flag or supplied false. The target returns incremental SSE content.
  • Actual: the preserved body retains its original delivery mode. The regression fails with HTTP 404: Switchyard route execution failed because the loopback mock requires "stream": true. That 404 is a test-fixture mismatch, not a claim that real providers necessarily return 404.

Observed before the fix:

test runtime::tests::stream_intercept_overrides_preserved_wire_flag ... FAILED
test result: FAILED. 0 passed; 1 failed; 44 filtered out

Environment

  • Switchyard commit: 1cdbac59c780197e852f7b9cac1837fa1b2132d0 (main)
  • Workspace version: 0.3.0; nemo-relay-plugin dependency: 0.10.1
  • Rust: 1.99.1
  • OS / arch: macOS / ARM64
  • Install path: source build
  • Inbound and target format: OpenAI Chat Completions through the native NeMo Relay plugin
  • Backend: local Wiremock HTTP server; no live model or credential required
  • Python: not involved in this Rust regression

Additional context

A local candidate synchronizes the preserved body's stream flag with the intercept mode before decoding, alongside the existing normalized flag assignment. With that change, all 45 Relay-plugin tests pass, including the regression's omitted/false/true caller variants. Workspace Clippy (--workspace --all-targets --locked -- -D warnings) and formatting also pass on the immediately preceding base; the new base changes only benchmark documentation/configuration.

Relevant source: request decoding and preserved raw request.

This report is limited to conflicting/omitted wire stream flags on the streaming intercept path. It does not claim all Switchyard requests fail or establish a customer-specific release blocker. No PR is open for this candidate.

主要言語
Rust
スター
3.7k
フォーク
386
平均マージ
1日 16時間
マージ済み PR(30日)
113

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA-NeMo/Switchyard のほかの issue

NVIDIA-NeMo/Switchyard の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。