Skip to content

Extract upstream response buffering and compatibility modules - #12004

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-split-upstream-response-js
Nov 23, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/refactor-split-upstream-response-js

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

The upstream response handler mixed fallback eligibility, error capture, and compatibility conversion in one large closure. This refactor separates those concerns while retaining response orchestration and existing exports.

  • Buffering: Isolate retry/fallback predicates, bounded error capture, and oversized-response forwarding; share per-response state through a capture object.
  • Compatibility: Centralize JSON/SSE transform selection, preserving protocol → wire API → Codex ordering and originating-provider semantics.
  • Packaging: Add both modules to the explicit Docker COPY list.
  • Regression coverage: Cover policy boundaries, capture limits, backpressure, transform ordering, classifier bypass, and Docker-layout loading.

@lpcox lpcox changed the title [WIP] Refactor split upstream-response.js into focused modules Extract upstream response buffering and compatibility modules Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 16:14
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 16:14

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.

🔵 Needs a closer look

The extraction shifts live-response ownership and callback boundaries across fallback suppression, overflow forwarding/backpressure, and completion diagnostics, making combined lifecycle verification exceed straightforward-review scope.

No open issues 🎉

What changed in this PR

This PR addresses #11997 by splitting API proxy response handling into focused buffering and compatibility modules, while retaining orchestration and existing exports.

Changes:

  • Extracts retry/fallback predicates, bounded error capture, and oversized-response forwarding.
  • Centralizes JSON and streaming transform selection, preserving protocol → wire API → Codex ordering.
  • Packages both modules and adds regression coverage for policy boundaries, backpressure, transforms, and Docker-layout loading.
File Description
containers/​api-proxy/​upstream-response.test.js Adds streaming, unchanged-response, and classifier-bypass coverage.
containers/​api-proxy/​upstream-response.js Delegates buffering and transform selection to the new modules.
containers/​api-proxy/​upstream-response-transforms.test.js Tests transform ordering, availability, and provider selection.
containers/​api-proxy/​upstream-response-transforms.js Centralizes JSON and streaming compatibility transform selection.
containers/​api-proxy/​upstream-response-buffering.test.js Tests buffering policies, capture limits, and overflow backpressure.
containers/​api-proxy/​upstream-response-buffering.js Encapsulates buffering policy, capture state, and overflow forwarding.
containers/​api-proxy/​protocol-compatibility.packaging.test.js Checks that both modules load from the Docker COPY layout.
containers/​api-proxy/​Dockerfile Includes both new modules in the proxy image.

Review effort: Balanced (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

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

@lpcox
lpcox merged commit 45ab065 into main Nov 23, 2026
39 of 42 checks passed
@lpcox
lpcox deleted the copilot/refactor-split-upstream-response-js branch November 23, 2026 16:51
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-response.js into focused modules

3 participants