Skip to content

Add audio transcriptions proxy support#1496

Open
EthenJ wants to merge 2 commits into
BigPizzaV3:mainfrom
EthenJ:codex/audio-transcriptions-proxy
Open

Add audio transcriptions proxy support#1496
EthenJ wants to merge 2 commits into
BigPizzaV3:mainfrom
EthenJ:codex/audio-transcriptions-proxy

Conversation

@EthenJ

@EthenJ EthenJ commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • add /v1/audio/transcriptions protocol proxy routing
  • forward multipart audio bodies unchanged to the active relay endpoint
  • normalize common relay base URL shapes for audio transcription endpoints
  • cover route matching, URL normalization, and multipart forwarding with tests

Test plan

  • cargo fmt --all
  • cargo test -p codex-plus-core --test protocol_proxy audio_transcriptions -- --nocapture
  • cargo check -p codex-plus-core
  • npm run vite:build in apps/codex-plus-manager
  • npm run check in apps/codex-plus-manager
  • cargo check --workspace after building frontend assets
  • local E2E: POST /v1/audio/transcriptions through Codex++ gateway using gpt-4o-mini-transcribe

@BigPizzaV3

Copy link
Copy Markdown
Owner

感谢贡献,音频转录代理这个方向有价值。审查后目前有一个需要先处理的阻塞问题,暂不合并:

handle_helper_connection() 仍通过 read_http_request() 读取请求,而该解析器只根据 Content-Length 判断请求体是否完整,不处理 Transfer-Encoding: chunked。音频 multipart 上传比普通 JSON 请求更可能由 SDK/流式文件使用 chunked 传输;这种情况下当前代码会在读完请求头后就结束读取,导致上游收到空或截断的音频体。

当前 audio_transcriptions_proxy_forwards_multipart_body 测试直接调用 open_audio_transcriptions_proxy_request(),绕过了本地 helper 的 TCP 请求解析,因此无法发现这个问题;测试体也只是短 ASCII 文本,没有验证二进制字节是否原样保留。

请补充:

  1. helper 对 chunked multipart 的正确读取/解码,或者在该入口明确限制并返回可识别错误,不能静默截断;
  2. 从本地 TCP helper 入口开始的完整回归测试,覆盖分段到达的请求头/请求体;
  3. 包含 0x00、非 UTF-8 字节的 multipart 文件内容,并断言上游收到的字节完全一致;
  4. 请求大小上限边界测试,并明确当前 32 MiB 限制是否符合预期。

修复后可以继续审查。

Decode chunked HTTP request bodies before forwarding multipart audio uploads, preserve binary payload bytes, and return explicit 400 or 413 responses for malformed and oversized requests.

Add TCP-level regression coverage for fragmented headers, irregular chunks, non-UTF-8 audio bytes, trailers, and the 32 MiB decoded body limit.

Thanks to @BigPizzaV3 for the detailed review and for identifying the helper request parsing gap.
@EthenJ

EthenJ commented Jul 14, 2026

Copy link
Copy Markdown
Author

Thanks @BigPizzaV3 for the detailed review and for catching the helper-layer request parsing gap.

I pushed an incremental fix that:

  • decodes Transfer-Encoding: chunked request bodies before forwarding;
  • preserves multipart audio data as raw bytes, including 0x00 and non-UTF-8 bytes;
  • rejects ambiguous or unsupported framing with HTTP 400;
  • returns HTTP 413 when the decoded body exceeds 32 MiB;
  • adds TCP-level regression coverage starting at the local helper;
  • covers fragmented headers, irregular chunks, chunk extensions, trailers, binary payloads, incomplete bodies, and exact size boundaries;
  • uses incremental chunk scanning to avoid repeatedly rescanning large uploads.

Validation

  • Standard multipart E2E: HTTP 200, exact transcript.
  • Raw HTTP/1.1 chunked E2E: HTTP 200, valid transcript.
  • Chunked helper body and upstream body were both 187,338 bytes.
  • Three concurrent multipart requests returned HTTP 200.
  • Core tests: 131 passed.
  • Protocol proxy tests: 46 passed.
  • Frontend build and TypeScript checks passed.
  • cargo check --workspace passed.
  • Release build passed.

The chunked E2E request was manually encoded over TCP with 95 irregular chunks, fragmented headers and chunk-size lines, binary WAV data, and a trailer header.

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.

2 participants