Repository navigation
feat: forward bridged routes in AI Gateway proxy mode - #30226
Conversation
|
/coder-agents-review |
|
Chat: Review in progress (15/15 reviewers complete) | View chat deep-review v0.13.0 | Round 1 | Status: Panel review (13 reviewers) About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
This PR adds the bridged-route forwarding engine (request replay, key failover, circuit breaker, response observation) behind an unexported method. Findings: 3 P1, 3 P2, 16 P3, 7 P4, 4 Nit. The P1s are breaker accounting of client aborts and two headers the interception path sets that forwarding does not (custom actor headers, Claude Platform workspace ID); each fails once #29726 connects this method.
Out of scope (needs a ticket or explicit acceptance by a human):
aibridge/circuitbreaker/circuitbreaker.go:132:statusCapturingWriterrecords a 1xx as the final status and itsFlushdrops errors, so every wrapper that needs either must route around it.aibridge/circuitbreaker/circuitbreaker.go:184:ExecuteignoreshandlerErr, so dial errors (written as 502) never open the breaker in either mode.aibridge/circuitbreaker/circuitbreaker.go:96:Getdoes not initialize the state gauge, so a recreated breaker keeps the previous gauge value.aibridge/headers/headers.go:195:PrepareClientHeaderskeepsCookieandCoder-Session-Token; the SDK path, passthrough (aibridge/passthrough.go:52), and the entrypoint (coderd/aibridged/http.go:103) forward Coder session credentials upstream.aibridge/passthrough.go:83: passthrough routes neither strip nor inject customActorHeaderNames, so client-supplied values reach upstream.aibridge/passthrough.go:38: the passthrough transport is not inrouter.transports, so retired routers keep its idle connections for 90s.aibridge/passthrough.go:63: client cancellation before upstream headers is logged at Warn as a reverse proxy error.coderd/aibridged/transport.go:188:pipeResponseWriter.WriteHeadertreats a 1xx as final, so in-process callers lose the real status when an upstream sends 100 or 103.aibridge/x/proxy/router.go:120:requestMuxbuilds a newServeMuxper request; cost grows with route count (not measured).aibridge/utils/http.go:16:MaxIdleConnsPerHoststays at 2, so HTTP/1.1 upstreams re-dial with TLS after each concurrent burst.
Notes:
handler.go:179:prepareForwarding,forward, andobservedBody.onReadhave no production caller until #29726; tests reachforwardthroughstartForwarding, a copy ofserve's setup that must be kept in sync by hand.handler.go:379:errorCapturingWritersends 1xx and flushes toclientand everything else to the breaker writer; any method added later must choose the right one.router.go:132:CloseIdleConnectionsat retirement does not close connections held by in-flight streams; they go idle afterwards and stay open untilIdleConnTimeout(90s).handler.go:96: with the client'sAccept-Encodingpreserved andDisableCompressionset,onReadreceives gzip bytes; the #29726 observer must decodeContent-Encoding.handler.go:194: the whole request body (up to 32 MiB) stays inrequestBufferfor the request lifetime, andbytes()makes a second copy.
🤖 This review was automatically generated with Coder Agents.
95b40d6 to
6417449
Compare
6417449 to
027f798
Compare
e76a1f9 to
8469a1a
Compare
c2fb367 to
1a6b56c
Compare
8469a1a to
91da7d1
Compare
1a6b56c to
053d24e
Compare
91da7d1 to
493dbba
Compare
053d24e to
6e9ddda
Compare
493dbba to
623e0f6
Compare
69d5489 to
51b2a5a
Compare
2d4de83 to
6cde609
Compare
51b2a5a to
130b4d6
Compare
bfa7e06 to
516011c
Compare
1709e41 to
6c0b3f8
Compare
516011c to
3795d4d
Compare
6c0b3f8 to
4cebde4
Compare
3795d4d to
48d8bfd
Compare
4cebde4 to
20a6229
Compare
48d8bfd to
fe6e3c1
Compare
20a6229 to
0f1cb56
Compare
fe6e3c1 to
fc49002
Compare
ae7c67c to
ac99ab1
Compare
16d2763 to
4056e73
Compare
a3c87f4 to
cba3dfe
Compare
4056e73 to
9072753
Compare
cba3dfe to
71384bd
Compare
9072753 to
b832964
Compare
71384bd to
e7effff
Compare
b832964 to
94fdf97
Compare
e7effff to
0942dd0
Compare
bb02faf to
2ebdb01
Compare
ssncferreira
left a comment
There was a problem hiding this comment.
LGTM, just some suggestions to make the code easier to read
Bridged routes now forward requests through the reverse proxy with key failover and the circuit breaker, and capture request and response bodies in TeeBuffers. Proxy errors are written by ErrorHandler, as in passthrough. ReverseProxy aborts a broken response stream by panicking with http.ErrAbortHandler, and the circuit breaker counts any panic as an upstream failure. forward recovers the abort and ServeHTTP re-panics after the breaker, so client disconnects no longer open the circuit. Interception recording is not connected yet. Generated by Coder Agents.
Enable bridged request forwarding in AI Gateway proxy mode. Responses are captured through
TeeBuffer.Proxies are created per-request reusing transports.
Handle
http.ErrAbortHandlerinside the circuit-breaker wrapper so aborted responses are classified by HTTP status before the panic is propagated.Generated by Coder Agents on behalf of @pawbana.