Skip to content

Deepen protocol_translation behind prepare_exchange for the standard Chat floor #442

Closed

Description

@NOirBRight

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 | NonForwardable

Do 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.py does not import codex_proxy.
  • Standard-floor fixtures in tests/test_chat_completions_gateway.py and 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

Out of scope

Activity

  1. NOirBRight commented on Aug 19, 2026

    @NOirBRight
    OwnerAuthor

    Standard-floor seam landed on the current branch:

    Handler still calls the older wrappers. Wiring CodexProxyHandler / RouteAttemptPlan.request_body onto this seam is the remaining work on this ticket. Collaboration V2 aliases remain #394.

  2. NOirBRight commented on Aug 19, 2026

    @NOirBRight
    OwnerAuthor

    Standard Chat floor seam is wired on current main (ahead of origin):

    • prepare_exchange / PreparedExchange / NonForwardable in protocol_translation.py
    • RouteAttemptPlan.request_body uses that seam for Responses→Chat
    • Handler wraps translation failures as UpstreamProtocolTranslationError
    • Vision Chat upstream uses the same seam
    • Tests: tests/test_prepare_exchange.py plus routing/Chat Gateway (762 passed here; the remaining 400 is the pre-existing missing OLLAMA_API_KEY host gap)

    The older _responses_request_to_chat_completion_body wrapper remains as a test/import-surface facade. Collaboration V2 aliases stay on #394.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    campaign:gateway-chatGateway deep modules and Codex↔Chat bridgeenhancementNew feature or requestneeds-triageMaintainer needs to evaluate this issuewayfinder:taskWayfinder implementation task

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions