• wwwillchen-bot's avatar
    Strip OpenAI itemId from persisted AI messages to prevent stale reference errors… · fb615c33
    wwwillchen-bot 提交于
    Strip OpenAI itemId from persisted AI messages to prevent stale reference errors but keep encrypted reasoning content (#2468)
    
    ## Summary
    - Strip `providerOptions.openai.itemId` (and `azure.itemId`) from
    persisted AI messages when parsing from DB
    - Prevents "Item with id not found" errors when OpenAI expires
    server-side stored items and the AI SDK sends `item_reference` payloads
    instead of full content
    - Adds comprehensive unit tests covering text parts, tool-call parts,
    reasoning parts (preserving `reasoningEncryptedContent`), legacy
    formats, and mixed provider options
    
    ## Test plan
    - [x] Unit tests added in `ai_messages_utils.test.ts` covering all
    stripping scenarios
    - [ ] Verify existing conversations with OpenAI models continue to work
    correctly
    - [ ] Verify that long conversations no longer produce "Item with id not
    found" errors
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2468">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Prevents "Item with id not found" errors by stripping openai/azure
    itemId from persisted message parts during parse, so the SDK always
    sends full content. Keeps long conversations stable without losing
    content.
    
    - **Bug Fixes**
    - Remove itemId under providerOptions/providerMetadata for openai and
    azure across text, tool-call, and reasoning parts, including legacy
    formats.
    - Preserve reasoningEncryptedContent and request encrypted reasoning via
    provider options; leave non-openai provider data and string-only
    messages unchanged.
    - Add unit tests covering stripping, legacy formats, mixed providers,
    and no-op cases.
    
    <sup>Written for commit a4c02d52ea9f25139d4b77bf1a2bdb9f663065f7.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    ---------
    Co-authored-by: 's avatarWill Chen <willchen90@gmail.com>
    Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
    fb615c33
名称
最后提交
最后更新
..
ai_messages_utils.ts 正在载入提交数据...
app_env_var_utils.ts 正在载入提交数据...
cleanFullResponse.ts 正在载入提交数据...
context_paths_utils.ts 正在载入提交数据...
debug_fetch.ts 正在载入提交数据...
dyad_tag_parser.ts 正在载入提交数据...
fallback_ai_model.ts 正在载入提交数据...
file_uploads_state.ts 正在载入提交数据...
file_utils.ts 正在载入提交数据...
findLanguageModel.ts 正在载入提交数据...
get_model_client.ts 正在载入提交数据...
git_author.ts 正在载入提交数据...
git_utils.ts 正在载入提交数据...
llm_engine_provider.ts 正在载入提交数据...
lm_studio_utils.ts 正在载入提交数据...
lock_utils.ts 正在载入提交数据...
mcp_consent.ts 正在载入提交数据...
mcp_manager.ts 正在载入提交数据...
mcp_tool_utils.ts 正在载入提交数据...
mention_apps.ts 正在载入提交数据...
neon_timestamp_utils.ts 正在载入提交数据...
ollama_provider.ts 正在载入提交数据...
path_utils.ts 正在载入提交数据...
port_utils.ts 正在载入提交数据...
process_manager.ts 正在载入提交数据...
provider_options.ts 正在载入提交数据...
read_env.ts 正在载入提交数据...
replacePromptReference.ts 正在载入提交数据...
retryOnLocked.ts 正在载入提交数据...
retryWithRateLimit.ts 正在载入提交数据...
ripgrep_utils.ts 正在载入提交数据...
runShellCommand.ts 正在载入提交数据...
safe_sender.ts 正在载入提交数据...
simpleSpawn.ts 正在载入提交数据...
start_proxy_server.ts 正在载入提交数据...
telemetry.ts 正在载入提交数据...
template_utils.ts 正在载入提交数据...
test_utils.ts 正在载入提交数据...
theme_utils.ts 正在载入提交数据...
thinking_utils.ts 正在载入提交数据...
token_utils.ts 正在载入提交数据...
vercel_utils.ts 正在载入提交数据...
versioned_codebase_context.ts 正在载入提交数据...