[bug] Relay streaming intercept preserves buffered upstream stream flag
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
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.
- Use the Relay plugin's existing
runtime_for_target("openai_chat", ...)test helper. It configuresswitchyard/defaultas a passthrough route totarget/model. - Pass an OpenAI Chat request to
decode_request(WireFormat::OpenAiChat, request, true):
{"model":"switchyard/default","messages":[{"role":"user","content":"hello"}]}
- Execute it with
execute_stream. A loopback mock expecting the outgoing body to contain"stream": trueis 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 suppliedfalse. The target returns incremental SSE content. - Actual: the preserved body retains its original delivery mode. The regression fails with
HTTP 404: Switchyard route execution failedbecause 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-plugindependency: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
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA-NeMo/Switchyard のほかの issue
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
NVIDIA-NeMo/Switchyard#1407 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NVIDIA-NeMo/Switchyard#1405 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
NVIDIA-NeMo/Switchyard#1395 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
NVIDIA-NeMo/Switchyard#1383 ·
メンテナーはふだん 1 日以内に返信
-
[Enhancement]: llm_classifier capability mode: derive capability_boundary from primary_rule instead of rejecting the verdict対応中かも @fede-kamel が 12 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NVIDIA-NeMo/Switchyard#1334 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
NVIDIA-NeMo/Switchyard の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ardia-browser/ardia#5810 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
UIUX の修正オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
aptos-labs/aptos-core#21119 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 8 日以内に返信