Skip to content

Conversation

@z2m2020
Copy link

@z2m2020 z2m2020 commented Dec 31, 2025

Fix: Omit reasoning id when store is false for third-party API compatibility

Problem

When using third-party OpenAI-compatible APIs (e.g., custom proxy endpoints) with GPT-5.x reasoning models, users encounter this error on the second message in a conversation:

Item with id 'rs_...' not found. Items are not persisted when `store` is set to false.

This happens because:

  1. The first response includes reasoning with an id (e.g., rs_0194963fc6ca...)
  2. On subsequent requests, OpenCode sends this id in the reasoning object
  3. Third-party APIs don't support OpenAI's item_reference storage mechanism
  4. The API cannot find the referenced item and returns an error

Solution

When store: false is configured, omit the id field from the reasoning object. The reasoning content is still sent via the summary field, maintaining functionality while avoiding the reference lookup.

Changes

  1. openai-responses-api-types.ts: Made id field optional in OpenAIResponsesReasoning type
  2. convert-to-openai-responses-input.ts: Don't include id when store is false

Testing

Tested with a third-party OpenAI-compatible API:

  • Before: Error on second message in conversation
  • After: Multi-turn conversations work correctly

Configuration

Users with third-party APIs need to add "store": false to their model options:

{
  "provider": {
    "openai": {
      "options": {
        "baseURL": "https://your-proxy.example.com/v1"
      },
      "models": {
        "gpt-5.1-codex": {
          "options": {
            "store": false
          }
        }
      }
    }
  }
}

Related Issues

…API compatibility

When using third-party OpenAI-compatible APIs with store: false, the
reasoning object should not include the id field. Third-party APIs don't
support OpenAI's item_reference mechanism, causing 'Item with id rs_...
not found' errors on subsequent requests.

This fix:
- Makes the id field optional in OpenAIResponsesReasoning type
- Omits the id field when store is false in convertToOpenAIResponsesInput

Fixes sst#2941, sst#4426, sst#4445
@rekram1-node
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants