openclaw - ✅(Solved) Fix Bug: Context serialization fails when switching from reasoning to non-reasoning models mid-session [1 pull requests, 2 comments, 2 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#78545Fetched 2026-05-07 03:35:33
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
2
Timeline (top)
commented ×2closed ×1cross-referenced ×1

When switching from a reasoning-capable model (e.g., venice/claude-sonnet-4-6) to a non-reasoning model (e.g., openai/gpt-5.5) mid-session, OpenClaw fails to sanitize reasoning items from the context payload before sending to OpenAI. OpenAI rejects the request with a 400 validation error.

Error Message

400 Item 'msg_01df1e7d03fcdcc20069fb58de4f908194b630002ad65511ec' of type 'message' was provided without its required 'reasoning' item: 'rs_01df1e7d03fcdcc20069fb58d8f8e88194a0e1d118390470f'.

Root Cause

When switching from a reasoning-capable model (e.g., venice/claude-sonnet-4-6) to a non-reasoning model (e.g., openai/gpt-5.5) mid-session, OpenClaw fails to sanitize reasoning items from the context payload before sending to OpenAI. OpenAI rejects the request with a 400 validation error.

Fix Action

Workaround

Restart the session (lose history) when switching between reasoning and non-reasoning models.

PR fix notes

PR #78547: fix(agents): strip reasoning items from context when switching to non-reasoning model

Description (problem / solution / changelog)

Root cause

convertResponsesMessages is called with replayReasoningItems: true unconditionally. When a session starts on a reasoning-capable model (e.g., venice/claude-sonnet-4-6, reasoning: true) and the user switches mid-session to a non-reasoning model (e.g., openai/gpt-5.5, reasoning: false), prior assistant messages with thinkingSignature fields get serialized as { type: "reasoning", encrypted_content: "..." } items in the context payload. OpenAI rejects the request with a 400 validation error because the non-reasoning API does not accept reasoning item types.

Fix

Gate replayReasoningItems on model.reasoning === true. When the target model does not explicitly support reasoning (reasoning: false or reasoning: undefined), reasoning items from prior messages are excluded from the payload. Text content from those assistant turns is preserved.

Changed files

  • src/agents/openai-transport-stream.tsreplayReasoningItems: model.reasoning === true (was true)
  • src/agents/openai-transport-stream.test.ts — 1 new test: "strips reasoning items from context when switching to a non-reasoning model"
  • CHANGELOG.md — Unreleased → Fixes entry

Proof

pnpm test src/agents/openai-transport-stream.test.ts
# Tests: 104 passed (104)

pnpm -s tsgo:core  # exit 0
pnpm -s build      # exit 0

Fixes #78545

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/openai-transport-stream.test.ts (modified, +65/-0)
  • src/agents/openai-transport-stream.ts (modified, +1/-1)

Code Example

400 Item 'msg_01df1e7d03fcdcc20069fb58de4f908194b630002ad65511ec' of type 'message' was provided without its required 'reasoning' item: 'rs_01df1e7d03fcdcc20069fb58d8f8e88194a0e1d118390470f'.

---

{
  "type": "message",
  "id": "c314cd87",
  "timestamp": "2026-05-06T16:14:39.281Z",
  "message": {
    "role": "assistant",
    "content": [{"type": "text", "text": "[assistant turn failed before producing content]"}],
    "api": "openai-responses",
    "provider": "openai",
    "model": "gpt-5.5",
    "stopReason": "error",
    "errorMessage": "400 Item 'msg_01df1e7d03fcdcc20069fb58de4f908194b630002ad65511ec' of type 'message' was provided without its required 'reasoning' item: 'rs_01df1e7d03fcdcc20069fb58d8f8e88194a0e1d118390470f'."
  }
}
RAW_BUFFERClick to expand / collapse

Bug Report: Context Serialization Fails When Switching from Reasoning to Non-Reasoning Models

Environment

  • OpenClaw Version: 2026.5.5 (b1abf9d)
  • OS: macOS 26.4.1 (arm64)
  • Node: 22.22.2

Summary

When switching from a reasoning-capable model (e.g., venice/claude-sonnet-4-6) to a non-reasoning model (e.g., openai/gpt-5.5) mid-session, OpenClaw fails to sanitize reasoning items from the context payload before sending to OpenAI. OpenAI rejects the request with a 400 validation error.

Error Message

400 Item 'msg_01df1e7d03fcdcc20069fb58de4f908194b630002ad65511ec' of type 'message' was provided without its required 'reasoning' item: 'rs_01df1e7d03fcdcc20069fb58d8f8e88194a0e1d118390470f'.

Reproduction Steps

  1. Start a session on a reasoning-capable model (e.g., venice/claude-sonnet-4-6)
  2. Have a few conversation turns (reasoning items are created in session context)
  3. Switch to a non-reasoning model via dropdown or session_status (e.g., openai/gpt-5.5)
  4. Send a new user message
  5. Result: Assistant turn fails with [assistant turn failed before producing content] and the above 400 error

Expected Behavior

OpenClaw should detect when switching to a non-reasoning model and:

  • Strip/omit reasoning items from the context payload
  • OR convert reasoning items to text-only format
  • OR trigger a sanitizing compaction that removes incompatible items

Actual Behavior

OpenClaw sends the full context including reasoning item references to OpenAI, which doesn't support the reasoning format and rejects the request.

Session Evidence

{
  "type": "message",
  "id": "c314cd87",
  "timestamp": "2026-05-06T16:14:39.281Z",
  "message": {
    "role": "assistant",
    "content": [{"type": "text", "text": "[assistant turn failed before producing content]"}],
    "api": "openai-responses",
    "provider": "openai",
    "model": "gpt-5.5",
    "stopReason": "error",
    "errorMessage": "400 Item 'msg_01df1e7d03fcdcc20069fb58de4f908194b630002ad65511ec' of type 'message' was provided without its required 'reasoning' item: 'rs_01df1e7d03fcdcc20069fb58d8f8e88194a0e1d118390470f'."
  }
}

Impact

  • Model switching mid-session is broken when reasoning capability differs
  • Users cannot switch from Venice (reasoning) → OpenAI (non-reasoning) without restarting session
  • Conversations lose continuity

Suggested Fix

Add context sanitization logic in the model request builder:

  1. Check if target model supports reasoning (via model capabilities)
  2. If not, strip reasoning items from message payload
  3. Preserve text content but omit reasoning references

Workaround

Restart the session (lose history) when switching between reasoning and non-reasoning models.

Related Models

  • Reasoning-capable: venice/claude-sonnet-4-6, venice/claude-opus-4-*
  • Non-reasoning: openai/gpt-5.5, openai/gpt-5-mini, openai/gpt-4o

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