Skip to content

Refactor upstream HTTP handling into focused modules - #11369

Merged
lpcox merged 5 commits into
mainfrom
copilot/refactor-upstream-http-js
Nov 9, 2026
Merged

lpcox merged 5 commits into
mainfrom
copilot/refactor-upstream-http-js

Conversation

Copilot AI commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

upstream-http.js combined request utilities, renewable credential handling, and fallback/retry logic in one large module. Split these responsibilities into focused modules while keeping existing callers compatible.

  • Request utilities: Move endpoint normalization, body framing, and cancellation handling to upstream-request-utils.js.
  • Authentication: Isolate renewable-auth header resolution and broker failure handling in upstream-auth.js.
  • Fallbacks: Move Copilot wire-API fallback and compatibility assessment, plus endpoint and model-endpoint retry handlers, to upstream-fallback.js.
  • Compatibility: Preserve the public exports from upstream-http.js and include the new modules in the API proxy Docker image.

Existing callers continue importing the same facade:

const { createSendUpstreamRequest } = require('./upstream-http');

Copilot AI changed the title [WIP] Refactor upstream-http.js into focused modules Refactor upstream HTTP handling into focused modules Nov 9, 2026
Copilot AI requested a review from lpcox November 9, 2026 16:13
@lpcox
lpcox marked this pull request as ready for review November 9, 2026 16:21
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 \
Comment thread containers/api-proxy/upstream-http.js Outdated
// Optional diagnostics cannot affect inference admission.
}
};
const assessCandidate = createFallbackAssessment({ origin, req });
@lpcox

lpcox commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot address all review feedback

Copilot AI commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address all review feedback

Addressed both review items in b02ef6c: fallback assessment now defaults to the current attempt’s target while preserving explicit overrides, and the extracted upstream modules trigger the routing smoke test.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit 6b86bc3 into main Nov 9, 2026
35 of 37 checks passed
@lpcox
lpcox deleted the copilot/refactor-upstream-http-js branch November 9, 2026 17:35
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.

[Refactoring] Split containers/api-proxy/upstream-http.js into focused modules

3 participants