Repository navigation
Refactor upstream HTTP handling into focused modules - #11369
Conversation
Co-authored-by: lpcox <[email protected]>
Co-authored-by: lpcox <[email protected]>
Co-authored-by: lpcox <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Provider-switch retries can incorrectly reject supported reasoning requests, while CI path filters omit the new modules and can skip routing smoke tests when those modules change.
2 open issues
What changed in this PR
Refactors the API proxy’s upstream HTTP handling into focused modules while preserving the existing upstream-http.js facade for callers.
Changes:
- Extracts request utilities and renewable-credential handling.
- Moves compatibility assessment and endpoint/model retry handlers into a fallback module.
- Rewires the facade and includes the new modules in the Docker image.
| File | Description |
|---|---|
containers/api-proxy/upstream-request-utils.js |
Extracts endpoint normalization, body framing, and cancellation handling. |
containers/api-proxy/upstream-http.js |
Wires extracted helpers while preserving public exports. |
containers/api-proxy/upstream-fallback.js |
Houses compatibility assessment and endpoint/model retries. |
containers/api-proxy/upstream-auth.js |
Isolates renewable authentication and broker-error responses. |
containers/api-proxy/Dockerfile |
Copies the three new modules into the proxy image. |
Review effort: Max (auto)
| model-resolver.js model-identity.js model-fallback.js model-fallback-chain.js model-utils.js model-body-rewriter.js proxy-utils.js oidc-adapter-utils.js adapter-factory.js anthropic-transforms.js claude-hosted-web.js codex-hosted-web.js hosted-web-policy.js \ | ||
| model-config.js model-recovery.js model-selector.js model-eligibility.js model-reasoning.js harness-observation.js scoped-auto-model.js key-validation.js server-factory.js startup.js \ | ||
| proxy-request.js request-headers.js trusted-service.js upstream-http.js proxy-guards.js proxy-error-handler.js http-client.js body-handler.js reasoning-effort-validation.js model-discovery.js management.js model-decision-diagnostics.js model-decision-diagnostics.schema.json model-decision-observation.js oidc-token-provider.js \ | ||
| proxy-request.js request-headers.js trusted-service.js upstream-http.js upstream-auth.js upstream-fallback.js upstream-request-utils.js proxy-guards.js proxy-error-handler.js http-client.js body-handler.js reasoning-effort-validation.js model-discovery.js management.js model-decision-diagnostics.js model-decision-diagnostics.schema.json model-decision-observation.js oidc-token-provider.js \ |
| // Optional diagnostics cannot affect inference admission. | ||
| } | ||
| }; | ||
| const assessCandidate = createFallbackAssessment({ origin, req }); |
|
@copilot address all review feedback |
Co-authored-by: lpcox <[email protected]>
Addressed both review items in |
|
✅ Copilot review passed with no inline comments. @copilot Add the |

upstream-http.jscombined request utilities, renewable credential handling, and fallback/retry logic in one large module. Split these responsibilities into focused modules while keeping existing callers compatible.upstream-request-utils.js.upstream-auth.js.upstream-fallback.js.upstream-http.jsand include the new modules in the API proxy Docker image.Existing callers continue importing the same facade: