fix(api-proxy): prevent stream_options injection into OpenAI Responses API requests#3805
Conversation
…injectStreamOptions
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
This PR updates the API proxy’s request body transformation logic to avoid injecting stream_options: { include_usage: true } into OpenAI Responses API (/responses) requests, which reject that field and can break streaming workflows.
Changes:
- Broaden the
/responsespath guard ininjectStreamOptions()to also match paths that omit a leading/(and still handle versioned forms). - Add a secondary “body-shape” guard: when the JSON body has
inputbut nomessages[], treat it as Responses-API-shaped and skip injection even if the path is unexpected. - Extend unit tests to cover bare-path variants and the new body-shape behavior.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/body-transform.js | Adjusts stream options injection guards to reliably exclude Responses API requests (path + body-shape). |
| containers/api-proxy/body-transform.test.js | Adds test coverage for bare-path responses variants and the new body-shape guard logic. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Cherry-picks the postprocess script fix that replaces standalone --skip-pull with --build-local, ensuring CI builds all containers (including api-proxy) from source code. This is critical for testing the stream_options.include_usage fix on this branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The real issue was model selection (gpt-5.5 not callable by our API key tier), not request body incompatibilities. Remove all three transforms added in this PR: - stripUnrecognizedToolTypes - stripEncryptedInclude - stripReasoningEffort Hardcode gpt-5.4 as the fallback model in the lock file since Codex CLI defaults to gpt-5.5 which hangs indefinitely with our key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
74d37bd to
e53047b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The CI API key cannot inference against gpt-5.5 (Codex CLI's default) — requests hang indefinitely with no error response. Use gpt-5.4 via the engine.model frontmatter field so the lock file hardcodes the model. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Smoke Test Results: Claude
Total: PASS
|
🔍 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. ✅
|
🔬 Smoke Test Results
PR: fix(api-proxy): prevent stream_options injection into OpenAI Responses API requests Overall: PARTIAL — MCP ✅, pre-computed test data unavailable (template substitution did not occur)
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Author: Overall: PASS (core BYOK path verified; pre-step outputs were not interpolated)
|
Chroot Runtime Version Comparison
Result: Not all tests passed. Python and Node.js versions differ between host and chroot environments. Go matches.
|
|
fix(api-proxy): prevent stream_options injection into OpenAI Responses API requests ✅ Playwright
|
Smoke Test Results
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL —
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
injectStreamOptions()was injectingstream_options: { include_usage: true }into Responses API (/responses) requests, which the API rejects outright. Codex CLI sends the path without a leading slash (api.path="responses"), bypassing the existing regex guard and crashing all Codex workflows with exit code 1.Changes
body-transform.jsinputbut nomessagesarray (canonical Responses API shape), skip injection regardless of path:body-transform.test.jsresponses,v1/responses,v1/responses?foo=1)inputandmessagesare present