Skip to content

Split API-proxy body handling into focused modules - #11874

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactoring-split-containers-api-proxy-body-handle
Nov 20, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/refactoring-split-containers-api-proxy-body-handle

Conversation

@lpcox

@lpcox lpcox commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

createBodyHandler mixes body collection, order-sensitive request transforms, and steering selection. This refactor separates those responsibilities while preserving request bytes and caller contracts.

  • Collection — body-collection.js: Owns the 10 MB limit, 400/413 handling, aborts, and span completion.
  • Pipeline — request-body-pipeline.js: Names each transform in a fixed-order array, preserving fallback snapshots and compatibility checks before wire translation.
  • Steering — steering-injection.js: Owns notice selection, ranking, claims, and delivery acknowledgement/release.
  • Integration: Retains the factory and sleep exports in body-handler.js and includes all three modules in the Docker image.
  • Behavior preservation: Adds regressions for exact body bytes, transform order, metadata, and collection lifecycle.

@lpcox lpcox changed the title [WIP] Refactor body handler in api proxy into focused modules Split API-proxy body handling into focused modules Nov 20, 2026
@lpcox
lpcox marked this pull request as ready for review November 20, 2026 18:00
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 18:00

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

The smoke-test workflow omits the extracted modules from its push paths, allowing main-branch changes limited to those modules to skip live model-routing checks.

1 open issue
What changed in this PR

Refactors the API proxy’s request-body handling into focused modules for #11871, keeping the existing factory interface and making transform order explicit.

Changes:

  • Separates body collection, ordered transformations, and steering selection.
  • Retains the factory and sleep exports and packages the new modules in the Docker image.
  • Adds regression tests for body bytes, transform order, metadata, and collection lifecycle.
File Description
containers/​api-proxy/​steering-injection.js Extracts notice selection, ranking, claims, and delivery tracking.
containers/​api-proxy/​request-body-pipeline.test.js Tests byte preservation, transform order, and metadata.
containers/​api-proxy/​request-body-pipeline.js Defines the fixed transform sequence and compatibility handling.
containers/​api-proxy/​Dockerfile Includes the three extracted modules in the image.
containers/​api-proxy/​body-handler.js Retains the factory and sleep exports while delegating implementation.
containers/​api-proxy/​body-collection.test.js Tests size limits, stream errors, aborts, and span completion.
containers/​api-proxy/​body-collection.js Extracts body collection and its error-handling lifecycle.

Review effort: Max (adaptive)

Comment on lines +11 to +12
const { createBodyCollector } = require('./body-collection');
const { transformRequestBody } = require('./request-body-pipeline');
@lpcox

lpcox commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Added the three extracted modules to the model-routing workflow’s push paths. Commit: afa1d92.

@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 35fb3a8 into main Nov 20, 2026
37 of 39 checks passed
@lpcox
lpcox deleted the copilot/refactoring-split-containers-api-proxy-body-handle branch November 20, 2026 20:36
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/body-handler.js into focused modules

3 participants