[PR #670] [MERGED] Fix OpenAI ChatGPT request shape #4721

Closed
opened 2026-10-22 04:10:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/670
Author: @cha1latte
Created: 5/11/2026
Status: ✅ Merged
Merged: 5/11/2026
Merged by: @cha1latte

Base: main ← Head: fix/openai-chatgpt-request-shape


📝 Commits (1)

  • 2d12bae Fix OpenAI ChatGPT request shape

📊 Changes

2 files changed (+62 additions, -14 deletions)

View changed files

📝 packages/server/src/services/llm/providers/openai.provider.ts (+31 -14)
📝 packages/server/test/openai-provider-reasoning.test.ts (+31 -0)

📄 Description

Linked issue

No linked issue yet; this came from a local provider bug report and one should be opened before submission if the team wants issue tracking.

Why this change

  • The OpenAI (ChatGPT) provider was sending the normal OpenAI Responses API request shape to the ChatGPT Codex endpoint.
  • That endpoint rejected chat/test requests with 400 errors such as {"detail":"Instructions are required"} and {"detail":"Unsupported parameter: max_output_tokens"}.

What changed

  • Special-cased the openai-chatgpt provider so Responses requests always send the Codex-compatible shape: stream: true, store: false, instructions, model, and input.
  • Omitted unsupported OpenAI API fields for this provider, including max_output_tokens, include, sampling parameters, reasoning options, text options, tools, and custom parameters.
  • Parsed OpenAI (ChatGPT) responses as streamed SSE even when the caller requested non-streaming output, matching the endpoint requirement.
  • Added regression coverage for the OpenAI (ChatGPT) request body.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex live provider verification passed using the local Codex ChatGPT auth session: the OpenAI (ChatGPT) provider returned {"ok":true,"text":"ok"}.
  • Focused regression passed: pnpm exec tsx --import ./test/setup-env.ts --test --test-name-pattern "OpenAI ChatGPT responses requests omit unsupported Codex parameters" test/openai-provider-reasoning.test.ts.
  • Baseline validation passed: pnpm check.
  • Diff hygiene passed: git diff --check.
  • Server logging hygiene passed: rg -n "console\\." packages/server/src/services/llm/providers/openai.provider.ts found no console statements.
  • No UI/manual browser verification is applicable; this is a backend provider request-shape fix.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs, schema, dependency, version, or release metadata changes.

UI evidence (if applicable)

N/A - backend provider request-shape fix.

Summary by CodeRabbit

  • Refactor

    • Optimized OpenAI ChatGPT provider request handling and improved streaming behavior management.
  • Tests

    • Added comprehensive test coverage for OpenAI ChatGPT provider request construction.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/670 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/11/2026 **Status:** ✅ Merged **Merged:** 5/11/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/openai-chatgpt-request-shape` --- ### 📝 Commits (1) - [`2d12bae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d12baef51952bedeb4772bfe2471cd4c425b519) Fix OpenAI ChatGPT request shape ### 📊 Changes **2 files changed** (+62 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+31 -14) 📝 `packages/server/test/openai-provider-reasoning.test.ts` (+31 -0) </details> ### 📄 Description ## Linked issue No linked issue yet; this came from a local provider bug report and one should be opened before submission if the team wants issue tracking. ## Why this change - The OpenAI (ChatGPT) provider was sending the normal OpenAI Responses API request shape to the ChatGPT Codex endpoint. - That endpoint rejected chat/test requests with 400 errors such as `{"detail":"Instructions are required"}` and `{"detail":"Unsupported parameter: max_output_tokens"}`. ## What changed - Special-cased the `openai-chatgpt` provider so Responses requests always send the Codex-compatible shape: `stream: true`, `store: false`, `instructions`, `model`, and `input`. - Omitted unsupported OpenAI API fields for this provider, including `max_output_tokens`, `include`, sampling parameters, reasoning options, text options, tools, and custom parameters. - Parsed OpenAI (ChatGPT) responses as streamed SSE even when the caller requested non-streaming output, matching the endpoint requirement. - Added regression coverage for the OpenAI (ChatGPT) request body. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Codex live provider verification passed using the local Codex ChatGPT auth session: the OpenAI (ChatGPT) provider returned `{"ok":true,"text":"ok"}`. - Focused regression passed: `pnpm exec tsx --import ./test/setup-env.ts --test --test-name-pattern "OpenAI ChatGPT responses requests omit unsupported Codex parameters" test/openai-provider-reasoning.test.ts`. - Baseline validation passed: `pnpm check`. - Diff hygiene passed: `git diff --check`. - Server logging hygiene passed: `rg -n "console\\." packages/server/src/services/llm/providers/openai.provider.ts` found no console statements. - No UI/manual browser verification is applicable; this is a backend provider request-shape fix. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs, schema, dependency, version, or release metadata changes. ## UI evidence (if applicable) N/A - backend provider request-shape fix. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Optimized OpenAI ChatGPT provider request handling and improved streaming behavior management. * **Tests** * Added comprehensive test coverage for OpenAI ChatGPT provider request construction. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/670) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:07 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4721
No description provided.