fix: Fix openai responses api issues#685
Merged
Henry-811 merged 1 commit intodev/v0.1.29from Dec 24, 2025
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix GPT-5 Reasoning Token Errors and Double Voting
Summary
This PR fixes two critical issues affecting GPT-5 reasoning models and multi-agent voting:
Closes MAS-181
Issues Fixed
Issue 1: GPT-5 Reasoning Token Errors
Error:
Root Causes:
idfield was being stripped fromfunction_callitems, breaking reasoning-to-function-call pairing required by OpenAI's Response APIprevious_response_id, response items were being added both manually AND automatically, causing duplicate reasoning itemsFixes:
massgen/formatter/_response_formatter.py: Preserveidfield in function_call items (required for reasoning pairing per LangChain PR #9082)massgen/backend/response.py: Only add response items manually when NOT usingprevious_response_idto avoid duplicatesIssue 2: Double Voting in Multi-Agent Workflows
Issue: Certain GPT-5 models (particularly gpt-5.1 and gpt-5.2) make multiple vote calls despite enforcement messages, causing workflow failures.
Model Behavior:
Fix: Instead of rejecting multiple votes, gracefully handle by taking the last vote as the agent's final decision.
Rationale:
Changes
Files Modified
massgen/formatter/_response_formatter.pyidfield for reasoning item pairingmassgen/backend/response.pyresponse_idpresencemassgen/orchestrator.pyLines Changed
Testing
Test Case 1: Reasoning Models
uv run massgen --automation --model gpt-5-mini "Create a simple website"Before: 400 error about reasoning tokens
After: ✅ Completes successfully
Test Case 2: Multi-Agent Voting with gpt-5.1/5.2
uv run massgen --config config.yaml "Create a simple website"Before:
Agent execution failed: 'agent1'(KeyError)After:
Verified Behavior
Related Documentation
Known Limitations
GPT-5 Model Variants: Some models (gpt-5.1, gpt-5.2) don't properly respond to tool error enforcement. This fix works around the limitation by handling multiple votes gracefully rather than relying on enforcement.
Recommendation: For critical voting scenarios, prefer models that respond to enforcement (gpt-5(-X), gpt-5.1-codex) or accept that multiple votes will be deduplicated to the last vote.
Migration Notes
No breaking changes. This is purely a bug fix that:
Users will see informational warnings when multiple votes are detected, but workflows will continue successfully.