#22503: docs: proposed fix for reasoning array error (#18480)
size: S
Cluster:
OpenAI Reasoning Enhancements
Related to #18480
This PR documents the proposed fix for the OpenAI reasoning array validation error:
```
400 Item '[]' of type 'reasoning' was provided without its required following item
```
## Problem Analysis
OpenAI's API requires each `reasoning` item to be followed by a content item. When reasoning items are the last item or appear consecutively, the API returns this validation error.
## Proposed Solution
- Filter out empty reasoning items before sending to API
- Ensure reasoning items are always paired with content items
- Add validation in message preparation layer
## Files Added
- `FIX-18480-proposed.md` - Detailed fix proposal
## Note
This fix requires deeper investigation into the pi-ai library internals. The proposed solution provides a starting point for discussion.
---
Looking for feedback from maintainers on the approach!
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `FIX-18480-proposed.md` documenting a proposed fix for the OpenAI reasoning array validation error (`400 Item '[]' of type 'reasoning' was provided without its required following item`).
However, this issue has already been resolved in the codebase:
- Implementation: `downgradeOpenAIReasoningBlocks` in `src/agents/pi-embedded-helpers/openai.ts:69`
- Documentation: `docs/reference/transcript-hygiene.md:98`
- Tests: `src/agents/pi-embedded-helpers.downgradeopenai-reasoning.e2e.test.ts`
- CHANGELOG entry: line 1671
The existing implementation drops orphaned reasoning blocks (those without following content) and is more sophisticated than the proposed approach. This documentation file may cause confusion since it presents a "proposed" fix for an already-solved problem.
<h3>Confidence Score: 4/5</h3>
- Safe to merge but may cause confusion about fix status
- Only adds documentation (no code changes), so no risk of bugs. However, documents a "proposed" fix for an already-resolved issue, which could confuse contributors unaware the fix is already in production.
- FIX-18480-proposed.md should clarify the fix is already implemented, or be removed
<sub>Last reviewed commit: c737277</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#18679: fix(agents): always downgrade orphaned OpenAI reasoning blocks
by battman21 · 2026-02-16
75.0%
#19407: fix(agents): strip thinking blocks on cross-provider model switch (...
by lailoo · 2026-02-17
74.5%
#16464: fix: harden OpenAI reasoning replay sanitization
by Swader · 2026-02-14
72.5%
#18935: fix(agents): suppress reasoning blocks from channel delivery
by BinHPdev · 2026-02-17
72.3%
#20945: fix: strip thinking blocks with field-name signatures from OpenAI-c...
by austenstone · 2026-02-19
71.5%
#18187: fix: tool summaries silently dropped when reasoningLevel is stream
by ayanesakura · 2026-02-16
71.3%
#17455: fix: strip content before orphan closing think tags
by jwt625 · 2026-02-15
70.7%
#16100: fix: convert unsigned thinking blocks to text to prevent signature ...
by claw-sylphx · 2026-02-14
70.5%
#10097: fix: add empty thinking blocks to tool call messages when thinking is…
by cyxer000 · 2026-02-06
69.8%
#20050: fix: Telegram polling regression and thinking blocks corruption (AI...
by Vaibhavee89 · 2026-02-18
69.8%