openclaw - 💡(How to fix) Fix openai-responses API: reasoning items break history replay with 400 error [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58967Fetched 2026-04-08 02:30:34
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

  1. Send a follow-up message → 400 error every time | store_reasoning: false on model | ❌ Config validation error: "Unrecognized key" | | stripHistory: true in compat | ❌ Config validation error: "Unrecognized key" |

Root Cause

The Azure OpenAI Responses API rejects the request because the conversation history contains a reasoning item without its paired output item.

Fix Action

Workaround

Setting "reasoning": false on the model prevents reasoning tokens from being generated, avoiding the issue. The model still works but without extended thinking capabilities.

Alternatively, using "api": "openai-completions" avoids the issue but doesn't pass reasoning_effort to the Azure endpoint, so reasoning doesn't activate.

Code Example

400 Item 'rs_XXXX' of type 'reasoning' was provided without its required following item

---

{
  "models": {
    "providers": {
      "azure-openai-responses": {
        "baseUrl": "https://<resource>.cognitiveservices.azure.com/openai/v1",
        "api": "openai-responses",
        "authHeader": false,
        "headers": { "api-key": "<key>" },
        "models": [{
          "id": "gpt-5.3-chat",
          "reasoning": true,
          "compat": { "supportsStore": false }
        }]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": { "primary": "azure-openai-responses/gpt-5.3-chat" },
      "thinkingDefault": "xhigh"
    }
  }
}
RAW_BUFFERClick to expand / collapse

Bug Description

When using the openai-responses API with reasoning: true on a model (Azure OpenAI GPT-5.3), the first message works correctly and generates reasoning tokens. However, every subsequent message in the same session fails with:

400 Item 'rs_XXXX' of type 'reasoning' was provided without its required following item

The Azure OpenAI Responses API rejects the request because the conversation history contains a reasoning item without its paired output item.

Steps to Reproduce

  1. Configure a provider with "api": "openai-responses" and a reasoning-capable model:
{
  "models": {
    "providers": {
      "azure-openai-responses": {
        "baseUrl": "https://<resource>.cognitiveservices.azure.com/openai/v1",
        "api": "openai-responses",
        "authHeader": false,
        "headers": { "api-key": "<key>" },
        "models": [{
          "id": "gpt-5.3-chat",
          "reasoning": true,
          "compat": { "supportsStore": false }
        }]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": { "primary": "azure-openai-responses/gpt-5.3-chat" },
      "thinkingDefault": "xhigh"
    }
  }
}
  1. Send any message to the agent → first response works, includes reasoning tokens
  2. Send a follow-up message → 400 error every time

Expected Behavior

Follow-up messages should work. OpenClaw should either:

  • Strip reasoning items from the input array when replaying history (since they're internal model artifacts, not user-facing content)
  • Or ensure reasoning items are always paired with their following output item when constructing the history replay

Actual Behavior

OpenClaw stores the full model response (including reasoning items with rs_* IDs) in the session JSONL file. On the next turn, it replays these items in the input array. The Responses API rejects this because:

  • The reasoning item is present without its required following item
  • Or the id fields from the original response are being sent back (known to cause issues per OpenAI docs)

Environment

  • OpenClaw version: 2026.3.31
  • Provider: Azure AI Foundry (cognitiveservices.azure.com)
  • API: openai-responses
  • Model: gpt-5.3-chat with reasoning: true
  • OS: Ubuntu 24.04 (Hetzner VPS)
  • Compaction mode: safeguard

What I've Tried

ApproachResult
store_reasoning: false on model❌ Config validation error: "Unrecognized key"
stripHistory: true in compat❌ Config validation error: "Unrecognized key"
reasoning: false on model✅ Works but disables reasoning entirely
Switch to openai-completions API✅ No 400 errors but reasoning_effort not passed to Azure
Session reset (rename .jsonl to .reset)✅ Fixes temporarily but breaks again on next follow-up
supportsStore: false in compatAlready set, doesn't help with reasoning items

Suggested Fix

When constructing the input array for the Responses API from session history:

  1. Strip all reasoning type items from the input (they're model-internal, not meant to be replayed)
  2. Or strip id fields from replayed items (per OpenAI guidance)
  3. Or add a compat.stripReasoning: true flag to control this behavior

Workaround

Setting "reasoning": false on the model prevents reasoning tokens from being generated, avoiding the issue. The model still works but without extended thinking capabilities.

Alternatively, using "api": "openai-completions" avoids the issue but doesn't pass reasoning_effort to the Azure endpoint, so reasoning doesn't activate.

extent analysis

TL;DR

Strip reasoning type items from the input array when constructing the history replay for the Azure OpenAI Responses API to prevent 400 errors.

Guidance

  • Modify the session history replay logic to exclude reasoning items, as they are internal model artifacts and not meant to be replayed.
  • Consider adding a compat.stripReasoning: true flag to control this behavior and provide flexibility in handling reasoning items.
  • As a temporary workaround, setting "reasoning": false on the model or using the "openai-completions" API can avoid the issue, but this may impact the model's extended thinking capabilities.

Example

No explicit code example is provided, but the suggested fix involves modifying the logic that constructs the input array for the Responses API to exclude reasoning type items.

Notes

The suggested fix assumes that the issue is caused by the inclusion of reasoning items in the session history replay. If this is not the case, further investigation may be necessary to identify the root cause of the issue.

Recommendation

Apply the workaround by setting "reasoning": false on the model, as this is a straightforward and temporary solution to avoid the 400 errors, although it may impact the model's performance. A more permanent fix would involve modifying the session history replay logic to handle reasoning items correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING