Summary
The LLM client currently discards all upstream HTTP response headers before they reach the Switchyard response builder. Any headers set by the upstream backend (or a proxy in front of it) — such as routing decisions, request IDs, or observability metadata — are lost.
This PR adds an upstream_headers: http::HeaderMap field to protocol::Response and preserves upstream headers through the full client → protocol → server pipeline.
Changes
- protocol: Added
upstream_headers: HeaderMap to Response struct
- libsy-llm-client: Captures headers in
send_once() before the response body is consumed; passes through EncodedResponse → call_rewrite_model → protocol::Response
- switchyard-server: Forwards non-reserved upstream headers to the downstream client after Switchyard's own routing headers
- Updated all downstream
Response constructors across libsy, switchyard-py, usage_metrics, and tests
Forwarding rules (in switchyard-server)
- Excluded: content-type, content-length, transfer-encoding, connection, date, server, x-request-id
- Excluded:
x-switchyard-* headers (set by Switchyard itself)
- All other upstream response headers are passed through
Breaking changes
None. The new field defaults to HeaderMap::new() in all constructors.
Summary
The LLM client currently discards all upstream HTTP response headers before they reach the Switchyard response builder. Any headers set by the upstream backend (or a proxy in front of it) — such as routing decisions, request IDs, or observability metadata — are lost.
This PR adds an
upstream_headers: http::HeaderMapfield toprotocol::Responseand preserves upstream headers through the full client → protocol → server pipeline.Changes
upstream_headers: HeaderMaptoResponsestructsend_once()before the response body is consumed; passes throughEncodedResponse→call_rewrite_model→protocol::ResponseResponseconstructors acrosslibsy,switchyard-py,usage_metrics, and testsForwarding rules (in
switchyard-server)x-switchyard-*headers (set by Switchyard itself)Breaking changes
None. The new field defaults to
HeaderMap::new()in all constructors.