Skip to content

feat: forward upstream response headers through protocol Response #480

Description

@lmvdz

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 EncodedResponsecall_rewrite_modelprotocol::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.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions