Skip to content

fix(replay): send through the upstream's own client, like forwarding does - #173

Merged
fylorn merged 1 commit into
mainfrom
fix/replay-provider-client
Sep 24, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/replay-provider-client

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Replaying a request whose upstream is `http://127.0.0.1:…\` came back as a system proxy's 503 page. Replay used the gateway's shared `reqwest` client, which reads the system proxy, while the data plane uses each upstream's own client (`direct` = no proxy at all, a named proxy = that proxy).

  • Replay now takes `AppState::client_for(upstream)` for both the credential exchange and the request, so it follows exactly the same outbound path as forwarding.
  • The shared fallback client (only used when an upstream is missing from the current runtime) is built with `no_proxy()`, matching its doc and the `direct` default.
  • `ControlState::http()` had no other caller; removed.

Other control-plane paths that reach upstreams were checked: the connection test and model list use `probe` with the upstream's client, L3 speed test uses `client_for`, L1 builds its hop from the upstream's proxy setting, ChatGPT/Z.ai logins use `client_for_provider`. Only replay was off.

Tests (`crates/tw-control/tests/replay.rs`): with a fake system proxy in the environment answering 503,

  • a `direct` upstream on loopback is replayed directly (was: 503 from the system proxy);
  • an upstream with its own HTTP proxy is replayed through that proxy (was: system proxy).
    Both fail on the old code.

🤖 Generated with Claude Code

…does

Replay sent the request with the gateway's shared client, which reads the
system proxy. A `direct` upstream on 127.0.0.1 therefore went through the
system proxy on replay (and came back as the proxy's 503 page), while the
data plane reaches it directly; an upstream with a named proxy bypassed
that proxy on replay. Replay now uses the same per-upstream client the
data plane uses, for both the credential exchange and the request.

The shared fallback client (used only when an upstream is missing from the
current runtime) is now direct too, matching its doc and the `direct`
default. `ControlState::http()` had no other caller and is gone.

The probe, model-list and latency (L1/L3) paths already use the
upstream's own client or its configured hop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 1645231 into main Sep 24, 2026
3 checks passed
@fylorn
fylorn deleted the fix/replay-provider-client branch September 24, 2026 09:02
@fylorn fylorn mentioned this pull request Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant