Skip to content

Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.

Rust

fix: preserve JSON object key order in proxied payloads (#439)

Hiroshi MORISHIGE0acde7b36259
diff --git a/Cargo.lock b/Cargo.lock
index ff7a91185..fbd4ca61a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2122,6 +2122,7 @@ version = "1.0.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
dependencies = [
+ "indexmap",
"itoa",
"memchr",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index d929d0c58..0fc5030a7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,7 +36,7 @@ rand = "0.10"
regex = "1"
reqwest = { version = "0.13.4", default-features = false, features = ["json", "rustls", "stream"] }
serde = { version = "1", features = ["derive"] }
-serde_json = "1"
+serde_json = { version = "1", features = ["preserve_order"] }
switchyard-libsy = { path = "crates/libsy", version = "0.2.0" }
switchyard-llm-client = { path = "crates/libsy-llm-client", version = "0.2.0" }
switchyard-protocol = { path = "crates/protocol", version = "0.2.0" }
diff --git a/crates/protocol/src/stream.rs b/crates/protocol/src/stream.rs
index b13b2c50c..7a70ca299 100644
--- a/crates/protocol/src/stream.rs
+++ b/crates/protocol/src/stream.rs
@@ -119,6 +119,7 @@ impl From<LlmResponseChunk> for LlmResponseStreamEvent {
/// Not `Clone` — the `Stream` variant owns a single-consumption stream. A buffered
/// backend returns `Agg` directly; a streaming one returns `Stream` and the consumer
/// drives it, folding to an [`AggLlmResponse`] when it needs the whole response.
+#[allow(clippy::large_enum_variant)]
pub enum LlmResponse {
/// Live, single-consumption response stream.
Stream(LlmResponseStream),