feat: add --aigateway-proxy-target flag - #27122
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Docs preview📖 View docs preview for |
b2b5847 to
45205a1
Compare
|
/coder-agents-review |
|
Chat: Review posted | View chat Review historydeep-review v0.9.0 | Round 2 | Last posted: Round 2, 15 findings (2 P2, 7 P3, 6 Nit), COMMENT. Review Finding inventoryFindings
Contested and acknowledgedCRF-7 (P3, enterprise/cli/aigatewaystart.go:292) - --verbose removal not documented
Round logRound 1Panel (16 reviewers). 2 P2, 5 P3, 4 Nit. Reviewed against 344a977..45205a1. Round 2Panel (5 reviewers). 10 R1 findings fixed, CRF-7 contested and closed (5/5). 2 P3, 2 Nit new. Reviewed against 3e85cfb..826ef6a. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
Clean architecture: the proxy target extraction and StartHTTPSpan refactor push deployment-topology knowledge to the configuration edge, keeping the proxy itself generic. The option inheritance guard (TestAIGatewayStart_InheritedOptions) is the best test in the PR: it prevents silent drift by forcing every new option in the source groups to be explicitly classified. The tracing middleware tests verify ordering invariants. Good work.
Severity count: 2 P2, 5 P3, 4 Nit.
The two P2s deserve attention before merge: the flag naming (--aigateway-proxy-target vs the group convention --ai-gateway-proxy-*) ships a permanent public API surface that requires a deprecation cycle to rename, and the double-nested logger (ai-gateway.ai-gateway) affects every log line from the standalone gateway.
"I tried to construct a scenario where the stated problem exists but the fix does not help. The only case I found: if the operator sets --aigateway-proxy-target to a standalone gateway URL that already serves at /api/v2/ai-gateway/, the URL construction would double the prefix. But this is standard URL configuration behavior, not a design flaw." (Pariston)
Process note: The PR title says "add --aigateway-proxy-target flag" but the diff also wires structured logging (replacing --verbose), OpenTelemetry tracing, Prometheus metrics, refactors option inheritance, and extracts StartHTTPSpan. The individual commit messages are clear, but a squash merge loses that context. The --verbose removal is a breaking change for operators using CODER_AI_GATEWAY_VERBOSE=true and should be documented in the PR body.
🤖 This review was automatically generated with Coder Agents.
0d8b072 to
826ef6a
Compare
|
/coder-agents-review |
There was a problem hiding this comment.
All 11 R1 findings addressed. 10 fixed cleanly, CRF-7 (--verbose removal) contested and closed by panel vote (5/5 accept: unreleased command, zero operators affected). The CRF-6 fix (query param rejection at startup) is particularly well done: prevents bad state rather than handling it at runtime.
Two new P3s and two Nits from the R2 panel, all documentation/naming consistency.
"The system-level consequence of the defended behavior: zero. No migration path is needed for a flag that was never exposed to users." (Razor, on CRF-7)
Severity count this round: 2 P3, 2 Nit.
🤖 This review was automatically generated with Coder Agents.
f5c52f9 to
18a735f
Compare
Documentation CheckUpdates Needed
Note: the auto-generated Automated review via Coder Agents |
| --ai-gateway-proxy-target=https://ai-gateway.example.com/ | ||
| ``` | ||
|
|
||
| The target is used as-is: the proxy appends only the provider and request path to it, and the URL must not include query parameters. |
|
|
||
| // Configure upstream proxy for tunneled (non-provider-host) CONNECT requests. | ||
| // Provider-host domains are MITM'd and forwarded to aibridge directly, | ||
| // Provider-host domains are intercepted and forwarded to AI Gateway directly, |
There was a problem hiding this comment.
I would prefer to keep MITM here as well as in the other comments that were replaced. Even though intercepted is correct, it could be considered for both MITM and tunneled requests, since the proxy "intercepts" all requests. MITM is the right term and is used elsewhere, including documentation, configuration values and in other places in the code.
2296a72 to
fd37ec9
Compare
ssncferreira
left a comment
There was a problem hiding this comment.
LGTM 👍 just some MITM renames missing in reload_test.go
|
|
||
| // requestResult is the outcome of sending a request through the proxy. | ||
| // Either err is set (CONNECT failed for a non-MITM'd host whose dial | ||
| // Either err is set (CONNECT failed for a non-intercepted host whose dial |
There was a problem hiding this comment.
MITM in this file as well 👀

Adds
--aigateway-proxy-targetoption todeploymentGroupAIGatewayProxythat defines URL to which intercepted requests should be forwarded to.Forward URL used to be hardcoded to
coderAPI.AccessURLpointing to embedded Gateway. With addition of standalone AI Gateway this needs to be configurable.Renamed
aibridgeproxyd.Server.coderAccessURLandcoderAccessPort->gatewayURLandgatewayPort+ option to better reflect reality.