-
Notifications
You must be signed in to change notification settings - Fork 873
[Feature]: keep Responses fetch helpers on a transport-only import boundary #2434
Copy link
Copy link
Closed
Labels
account-poolOAuth, credentials, Codex pool, quota, failover, plansOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestNew feature or requestlanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainOriginal PR closed after landing via a maintainer merge trainproxyHTTP proxy, routing, reverse-proxy / management authHTTP proxy, routing, reverse-proxy / management authstreamingSSE, WebSocket, terminal stream framesSSE, WebSocket, terminal stream framestoolstool_calls, MCP, web-search / sidecar toolstool_calls, MCP, web-search / sidecar tools
Description
Metadata
Metadata
Assignees
Labels
account-poolOAuth, credentials, Codex pool, quota, failover, plansOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestNew feature or requestlanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainOriginal PR closed after landing via a maintainer merge trainproxyHTTP proxy, routing, reverse-proxy / management authHTTP proxy, routing, reverse-proxy / management authstreamingSSE, WebSocket, terminal stream framesSSE, WebSocket, terminal stream framestoolstool_calls, MCP, web-search / sidecar toolstool_calls, MCP, web-search / sidecar tools
Area
Proxy and routing
What are you trying to accomplish?
Keep
src/server/responses/fetch-helpers.tsas a true transport leaf so ordinary Responses, compact, and native-chat imports load only the code required for request pacing, upstream HTTP-version policy, and the optional Codex WebSocket transport.What prevents this today?
The original
responses.tssplit in commite7f24b952copied the monolith import header intofetch-helpers.ts. The file now has 39 distinct runtime import specifiers even though its exports use only the WebSocket transport, request pacing, upstream HTTP-version helper, and type-only server/config declarations.Because ESM evaluates static imports, importing
safeHostLabel,providerFetch, orfetchWithHeaderTimeoutcurrently reaches a 326-module transitive graph including bridge, config, parser, compaction, routing, combos, OAuth, web-search, vision, Codex auth/routing, retries, sidecars, logging, and relay modules. A static walk of the imports actually used by the helper reduces that graph to six modules.This is an ownership and startup-isolation defect, not a request-behaviour feature:
src/server/chat-native.tsshould not pull the full routed Responses/sidecar graph merely to call a transport helper.What should OpenCodex do?
Preserve every public helper and wire behaviour while removing stale runtime imports from
fetch-helpers.ts. Add a repository regression that locks the module to a small explicit runtime-import allowlist and ignores type-only edges. Document why the helper must remain transport-only so a future mechanical extraction or copy does not recreate the eager graph.The change must not move request logic, change pacing, alter HTTP/WebSocket selection, or modify authentication, credentials, provider routing, retries, response parsing, or sidecar behaviour.
Example usage or interface
No CLI or config change is expected. The maintained invariant should be equivalent to:
Importing
safeHostLabelfromsrc/server/chat-native.tsmust continue to behave identically without eagerly evaluating unrelated Responses, combo, OAuth, web-search, or vision modules.Alternatives or workarounds
Leaving the stale imports in place is functionally tolerated today because most imported modules avoid harmful top-level side effects, but it makes startup/import ownership depend on that accidental property and increases the surface loaded by every consumer.
Moving the helpers again would add churn without fixing the root cause. The smallest durable change is to prune the copied imports and pin the leaf boundary with a focused source-graph test.
Additional context
dev:4f41a8e936141af7ee828e335da314b9dc1ef761e7f24b952Checks