Skip to content

Fix sparse provider message block arrays#518

Merged
ilvalerione merged 1 commit intoneuron-core:3.xfrom
qwertyquest:openai-responses-reasoning
Mar 23, 2026
Merged

Fix sparse provider message block arrays#518
ilvalerione merged 1 commit intoneuron-core:3.xfrom
qwertyquest:openai-responses-reasoning

Conversation

@qwertyquest
Copy link

Bug

Ran into an issue causing an invalid type issue with OpenAI Responses API. Neuron's provider message mappers can emit sparse PHP arrays for message content blocks.

When a message contains mixed blocks like [ReasoningContent, TextContent], the mapper drops unsupported blocks with array_filter(array_map(...)). array_filter() preserves numeric keys, so if index 0 is removed and index 1 remains, PHP JSON-encodes the result as an object instead of a list.

That breaks OpenAI Responses with errors like:

Invalid type for 'input[n].content': expected one of an array of objects or string, but got an object instead.

Direct example:

  • Assistant message content blocks: [reasoning, text]
  • Mapped PHP array becomes: [1 => ['type' => 'output_text', 'text' => 'Hello']]
  • JSON becomes:
{"1":{"type":"output_text","text":"Hello"}}

instead of:

[{"type":"output_text","text":"Hello"}]

Fix

Wrapped provider mapBlocks() methods with array_values to reindex after filtering and added regression tests.

@ilvalerione ilvalerione merged commit 8cadae1 into neuron-core:3.x Mar 23, 2026
10 of 11 checks passed
@qwertyquest qwertyquest deleted the openai-responses-reasoning branch March 23, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants