Repository navigation
[codex] fix MiniMax OpenAI response formatting #5896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhukangfeng
wants to merge
4
commits into
QuantumNous:main
Choose a base branch
from
zhukangfeng:codex/minimax-openai-response-sanitize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
docs/superpowers/plans/2026-07-04-minimax-openai-response-sanitize.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # MiniMax OpenAI Response Sanitization Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Fix MiniMax OpenAI-format text responses so provider-specific fields do not leak into strict OpenAI clients. | ||
|
|
||
| **Architecture:** Keep the fix local to the MiniMax adaptor. MiniMax already delegates text response handling to the OpenAI adaptor; the implementation will force the existing OpenAI DTO formatting path before delegation. | ||
|
|
||
| **Tech Stack:** Go 1.22+, Gin test context, `github.com/stretchr/testify/require` and `assert`. | ||
|
|
||
| --- | ||
|
|
||
| ### Task 1: Non-Streaming Regression Test | ||
|
|
||
| **Files:** | ||
| - Modify: `relay/channel/minimax/adaptor_test.go` | ||
|
|
||
| - [ ] **Step 1: Write the failing test** | ||
|
|
||
| Add a test that sends a MiniMax-style non-streaming response with extra top-level and message fields through `Adaptor.DoResponse`. Assert the recorded response keeps OpenAI fields and omits MiniMax-only fields. | ||
|
|
||
| - [ ] **Step 2: Run test to verify it fails** | ||
|
|
||
| Run: `go test ./relay/channel/minimax -run TestDoResponseForOpenAITextStripsMiniMaxFields -count=1` | ||
|
|
||
| Expected before implementation: FAIL because `input_sensitive`, `base_resp`, `name`, or `audio_content` appears in the response body. | ||
|
|
||
| ### Task 2: Streaming Regression Test | ||
|
|
||
| **Files:** | ||
| - Modify: `relay/channel/minimax/adaptor_test.go` | ||
|
|
||
| - [ ] **Step 1: Write the failing test** | ||
|
|
||
| Add a streaming test that sends SSE chunks containing MiniMax-only `delta.name`, `delta.audio_content`, and a final chunk containing `choices[].message`. Assert the downstream SSE omits those fields and still emits `[DONE]`. | ||
|
|
||
| - [ ] **Step 2: Run test to verify it fails** | ||
|
|
||
| Run: `go test ./relay/channel/minimax -run TestDoResponseForOpenAIStreamStripsMiniMaxFieldsAndMessage -count=1` | ||
|
|
||
| Expected before implementation: FAIL because raw SSE chunks are forwarded with `name`, `audio_content`, or `message`. | ||
|
|
||
| ### Task 3: Minimal Implementation | ||
|
|
||
| **Files:** | ||
| - Modify: `relay/channel/minimax/adaptor.go` | ||
| - Modify: `relay/channel/openai/relay-openai.go` | ||
|
|
||
| - [ ] **Step 1: Force formatting for MiniMax OpenAI text responses** | ||
|
|
||
| In `Adaptor.DoResponse`, before delegating to `openai.Adaptor`, set `info.ChannelSetting.ForceFormat = true` when: | ||
|
|
||
| - `info.RelayFormat` is `types.RelayFormatOpenAI` | ||
| - `info.RelayMode` is `constant.RelayModeChatCompletions` | ||
|
|
||
| - [ ] **Step 2: Run targeted tests** | ||
|
|
||
| In `OpenaiHandler`, when `forceFormat` is true, clear `simpleResponse.Choices[i].Message.Name` before marshalling the response. | ||
|
|
||
| - [ ] **Step 3: Run targeted tests** | ||
|
|
||
| Run: `go test ./relay/channel/minimax -count=1` | ||
|
|
||
| Expected after implementation: PASS. | ||
|
|
||
| ### Task 4: Related Verification | ||
|
|
||
| **Files:** | ||
| - No production edits expected. | ||
|
|
||
| - [ ] **Step 1: Run delegated OpenAI handler tests** | ||
|
|
||
| Run: `go test ./relay/channel/openai -count=1` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| - [ ] **Step 2: Run touched relay package tests** | ||
|
|
||
| Run: `go test ./relay/channel/minimax ./relay/channel/openai -count=1` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| - [ ] **Step 3: Inspect diff** | ||
|
|
||
| Run: `git diff -- relay/channel/minimax/adaptor.go relay/channel/minimax/adaptor_test.go docs/superpowers/specs/2026-07-04-minimax-openai-response-sanitize-design.md docs/superpowers/plans/2026-07-04-minimax-openai-response-sanitize.md` | ||
|
|
||
| Expected: Only the planned MiniMax adaptor, tests, and docs changed. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Normalize the task heading levels.
The file jumps from the H1 straight to H3 task headings, which triggers the markdownlint
MD001warning and makes the outline harder to scan. Promote these sections to H2 (or add an H2 parent) so the hierarchy is consistent.🧰 Tools
🪛 LanguageTool
[grammar] ~87-~87: Ensure spelling is correct
Context: ...md` Expected: Only the planned MiniMax adaptor, tests, and docs changed.
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🪛 markdownlint-cli2 (0.22.1)
[warning] 13-13: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents
Source: Linters/SAST tools