ClawKit Logo
ClawKitReliability Toolkit

Fix GPT-5.2 Reasoning 400 Errors

New Pattern: Reasoning Blocks

GPT-5.2 uses a new reasoning content type. OpenAI requires these blocks to be strictly followed by a text or tool_call block. If your session history gets out of sync, the API will return a 400 Bad Request.

If you see errors like required following item missing or invalid message sequence specifically when using GPT-5.2, your session transcript is likely carrying stale or unpaired reasoning blocks.

Next Step

Fix now, then reduce repeat incidents

If this issue keeps coming back, validate your setup in Doctor first, then harden your config.

Symptoms

Error: OpenAI API error: 400 required following item missing for reasoning block
LLM request rejected: invalid message sequence at index 14
Recurring 400 errors that only go away after /clear

Fix 1: Reset the Session History

The fastest way to get your agent running again is to wipe the current session history. This removes the unpaired reasoning blocks that are causing the API rejection.

Telegram / Discord / Slack
/clear

Note: This will make the agent forget the current conversation context.

Fix 2: Update OpenClaw (Permanent Fix)

OpenClaw version v2026.2.28 and higher include a "Transcript Repair" feature. It automatically detects orphaned reasoning blocks in your .jsonl logs and strips them before sending the request to OpenAI.

Update to latest version
npm install -g openclaw@latest

Fix 3: Disable Reasoning Storage

If you prefer to stay on an older version of OpenClaw, you can prevent reasoning blocks from being saved to history at all by adjusting your provider configuration.

Update openclaw.json

"providers": {
  "openai": {
    "config": {
      "model": "gpt-5.2",
      "includeReasoningInHistory": false // Set this to false
    }
  }
}

Why This Happens

Reasoning models (like GPT-5.2 or o1) don't just return text; they return a chain of thought. OpenAI mandates that a reasoning block cannot be the last item in a message array if that message is followed by another assistant message.

When OpenClaw truncates or compacts logs for long conversations, it sometimes accidentally cuts the "companion" text block that was supposed to follow the reasoning block.

Hybrid Strategy

If you heavily rely on GPT-5.2 reasoning but want to save costs, consider using DeepSeek V3 for routine tasks and only switching to GPT-5.2 when high-intensity reasoning is required.

Did this guide solve your problem?