[PR #6501] fix(provider): omit reasoning id when store is false for third-party … #11938

Closed
opened 2026-02-16 18:16:52 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6501

State: closed
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6501 **State:** closed **Merged:** No --- ## 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: ```json { "provider": { "openai": { "options": { "baseURL": "https://your-proxy.example.com/v1" }, "models": { "gpt-5.1-codex": { "options": { "store": false } } } } } } ``` ### Related Issues - Fixes #2941 - Fixes #4426 - Fixes #4445
yindo added the pull-request label 2026-02-16 18:16:52 -05:00
yindo closed this issue 2026-02-16 18:16:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11938