Repository navigation
Deepen protocol_translation behind prepare_exchange for the standard Chat floor #442
Copy link
Copy link
Closed
Labels
campaign:gateway-chatGateway deep modules and Codex↔Chat bridgeGateway deep modules and Codex↔Chat bridgeenhancementNew feature or requestNew feature or requestneeds-triageMaintainer needs to evaluate this issueMaintainer needs to evaluate this issuewayfinder:taskWayfinder implementation taskWayfinder implementation task
Description
Part of #441
Outcome
Deepen the existing src-python/protocol_translation.py seam so the Gateway handler does not keep growing Chat/Responses helpers. Callers see one small interface:
prepare_exchange(request_body, route_attempt, tool_plan) -> PreparedExchange | NonForwardableDo not create a second Chat adapter module. Do not add protocol adaptation back into codex_proxy.py (ADR-0001).
Required behavior
PreparedExchange hides:
- Responses → Chat request translation
- Chat JSON → Responses
- progressive stream decoding
- a request-scoped tool/call/item identity registry
- the adaptation summary
- fail-closed reasons
The first landable slice is the standard Chat floor, not Collaboration V2:
- progressive text
- multi-turn history
- standard function declaration / call / result
- usage / error / cancellation
- stable IDs
- exactly one terminal
- byte-identical upstream bodies for the same caller body, protocol, capabilities, and ordered tool declarations
- no hidden fallback to Responses, Official, another model, or another Provider
Unknown or irreversible semantics raise UnsupportedProtocolTranslationError (or NonForwardable) before upstream sampling.
Old helpers stay importable from codex_proxy via re-export until callers migrate. No test-import rewrite in this issue.
Acceptance criteria
- Handler / RouteAttempt code paths that need Chat translation go through
prepare_exchange(or a documented thin wrapper that only logs Gateway policy). -
protocol_translation.pydoes not importcodex_proxy. - Standard-floor fixtures in
tests/test_chat_completions_gateway.pyand the existing routing Chat fixtures pass. - Same input + capabilities + ordered declarations produce a byte-identical upstream body.
- Unknown fields / items fail closed and cannot disappear.
- Collaboration V2 remains out of scope here and stays on 0.1.8 Beta6: Implement generic Collaboration V2 over Chat Completions #394.
Blocked by
- 0.1.8 Beta6: Define the real Codex-to-Chat runtime-field and V2 item contract #253
- 0.1.8 Beta6: Define progressive Chat and Collaboration V2 streaming #254
Out of scope
- RoutePlan / SSE extraction (Refactor: extract route-plan and SSE helper clusters from codex_proxy.py monolith #413)
- Level-3 DAG cleanup (Cleanup: remove unused Level-3 dynamic-DAG subagent machinery from production path #414)
- V2 tools, aliases, and lifecycle (0.1.8 Beta6: Implement generic Collaboration V2 over Chat Completions #394 / 0.1.8 Beta6: Verify the complete generic Chat Collaboration V2 lifecycle #395)
- Provider-named qualification (0.1.8 Beta6: Complete the GLM-5.2 Ollama Chat and V2 CLI path #285 / 0.1.8 Beta6: Complete the K2.7 Code Ollama Chat and V2 CLI path #286 / 0.1.8 Beta6: Complete the DeepSeek V4 Flash 0731 Chat CLI path #396)
- Splitting
tests/test_routing.py
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
campaign:gateway-chatGateway deep modules and Codex↔Chat bridgeGateway deep modules and Codex↔Chat bridgeenhancementNew feature or requestNew feature or requestneeds-triageMaintainer needs to evaluate this issueMaintainer needs to evaluate this issuewayfinder:taskWayfinder implementation taskWayfinder implementation task
Activity
NOirBRight commentedon Aug 19, 2026
Standard-floor seam landed on the current branch:
protocol_translation.prepare_exchange/PreparedExchange/NonForwardabletests/test_prepare_exchange.pystore=true/ non-default transport controls, matching 0.1.8 Beta6: Generate the runtime-derived Chat and Collaboration V2 conversion matrix #66.Handler still calls the older wrappers. Wiring
CodexProxyHandler/RouteAttemptPlan.request_bodyonto this seam is the remaining work on this ticket. Collaboration V2 aliases remain #394.NOirBRight commentedon Aug 19, 2026
Standard Chat floor seam is wired on current
main(ahead of origin):prepare_exchange/PreparedExchange/NonForwardableinprotocol_translation.pyRouteAttemptPlan.request_bodyuses that seam for Responses→ChatUpstreamProtocolTranslationErrortests/test_prepare_exchange.pyplus routing/Chat Gateway (762 passed here; the remaining 400 is the pre-existing missingOLLAMA_API_KEYhost gap)The older
_responses_request_to_chat_completion_bodywrapper remains as a test/import-surface facade. Collaboration V2 aliases stay on #394.feat(gateway): add prepare_exchange seam for Responses-Chat conversion (
feat(gateway): route Chat conversions through prepare_exchange (#442)