Skip to content

GPT-5.4 Responses API: encrypted_content item_id mismatch after model switch or compaction #70654

@jakepresent

Description

@jakepresent

Bug Description

When switching to GPT-5.4 (Responses API) mid-session after using a Claude model, the API rejects requests with:

400 The encrypted content for item rs_XXXX could not be verified.
Reason: Encrypted content item_id did not match the target item id.

This happens consistently and the session becomes stuck in an error loop - every subsequent GPT-5.4 request fails with the same error until the session is cleared.

Root Cause

GPT-5.4 uses the Responses API with reasoning.encrypted_content. When conversation history contains compacted/restructured content from a prior model (e.g. Claude), the encrypted reasoning item references become stale. The Responses API validates that encrypted_content item IDs match their target items, and compaction or cross-model history restructuring breaks this invariant.

The existing downgradeOpenAIReasoningBlocks and downgradeOpenAIFunctionCallReasoningPairs functions handle some orphaned reasoning scenarios, but do not cover the case where encrypted content item IDs are invalidated by compaction or model switching.

Reproduction

  1. Start a session on claude-opus-4.6 with thinking enabled
  2. Have a multi-turn conversation (long enough to trigger compaction)
  3. Switch to gpt-5.4 via /gpt or /model gpt
  4. Send any message → 400 error
  5. Every subsequent GPT-5.4 message in this session also fails

Expected Behavior

OpenClaw should strip encrypted_content reasoning items from conversation history when:

  • Switching between model families (Claude ↔ GPT)
  • After compaction restructures the conversation history
  • When the target model uses a different API format (chat/completions vs Responses API)

Workaround

Send /clear before switching to GPT-5.4 to reset the session history.

Environment

  • OpenClaw: 2026.4.21
  • Provider: github-copilot (enterprise)
  • Source model: claude-opus-4.6 (thinking: high)
  • Target model: gpt-5.4 (Responses API, xhigh)
  • Compaction: triggered before model switch

Gateway Logs

embedded run agent end: isError=true model=gpt-5.4 provider=github-copilot
error=LLM request failed: provider rejected the request schema or tool payload.
rawError=400 The encrypted content for item rs_933f7a8c9f6dc069 could not be verified.
Reason: Encrypted content item_id did not match the target item id.

embedded run failover decision: stage=assistant decision=surface_error reason=format
from=github-copilot/gpt-5.4

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions