-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Confirm this is a Node library issue and not an underlying OpenAI API issue
- This is an issue with the Node library
Describe the bug
Reasoning+message items must appear as consecutive pairs in input, but nothing documents this. Common multi-turn patterns silently produce orphaned items → 400 on the next turn.
This broke OpenClaw (64.9k forks) on gpt-5.3-codex. They had to add downgradeOpenAIReasoningBlocks() to strip orphan reasoning items.
The most common failure: filtering response.output to keep only messages (dropping reasoning) → 400: Item 'msg_...' of type 'message' was provided without its required preceding item of type 'reasoning'.
Tested in JS, Python, Go, Java, .NET — identical results across all 5 SDKs. This is an API-level constraint, not SDK-specific. The SDK types don't prevent building input arrays that violate it.
| Model | A (all items) | B (msgs only) |
|---|---|---|
| gpt-5.3-codex (reasoning=high) | PASS | FAIL |
| o4-mini | PASS | FAIL* |
* Nondeterministic — o4-mini sometimes returns reasoning-only output (no message), so B passes on those runs since there's no message to orphan. Codex with reasoning=high reliably returns both items, making it a deterministic repro.
Workaround: previous_response_id. For manual history, always pass reasoning+message pairs together.
Related:
- Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations across all SDKs openai-openapi#536 (spec root cause)
- Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations openai-python#3009 (same bug, Python SDK)
- [BUG] Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations openai-dotnet#1050 (same bug, .NET SDK)
- Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations openai-go#631 (same bug, Go SDK)
- Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations openai-java#710 (same bug, Java SDK)
- openclaw/openclaw#49167 (64.9k forks, production breakage)
- Error "Item ‘rs_ABCD’ of type ‘reasoning’ was provided without its required..." when using CodeInterpreter openai-python#2561 (open since Aug 2025)
- GPT-5 + tool calls: Error code: 400 - Item 'rs_...' of type 'reasoning' was provided without its required following item. openai-agents-python#1660 (Agents SDK)
To Reproduce
import OpenAI from "openai";
const client = new OpenAI();
const conversation: any[] = [];
for (const msg of ["Write a Python prime checker.", "Add type hints.", "Add docstrings."]) {
conversation.push({ role: "user", content: msg });
const response = await client.responses.create({
model: "gpt-5.3-codex",
input: conversation,
max_output_tokens: 300,
reasoning: { effort: "high" },
});
// Common pattern: keep only messages, discard reasoning
for (const item of response.output) {
if (item.type === "message") {
conversation.push(item); // orphan message → 400 on next turn
}
}
}
// Turn 2 → 400: Item 'msg_...' was provided without its required preceding itemReproduced on o4-mini and gpt-5.3-codex.
OS
Windows 11, also reproduced on Linux
Node version
Node v24.x
Library version
openai v6.32.0