Repository navigation
fix(runtime): suppress OpenAI store field for Mistral Chat Completions - #2540
Conversation
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review of the Mistral `store` suppression change. The compat helper mirrors the existing DeepSeek/Zhipu patterns and the tests cover hosted, custom, and OpenAI rows. One likely functional gap is that `mistralCompat` is spread after `deepseekCompat`, so `{supportsStore:false}` can overwrite a DeepSeek/Zhipu compat entry if those presets also define `supportsStore`—but this depends on shared code not shown. No concrete added-line defect is sufficiently evidenced from the supplied diff alone. Verification limits: no tests or repository access; all claims are unverified.
No evidenced findings in the supplied diff.
Head: deef429
Base: 7254a04
CI: no-statuses; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
|
Review: this fixes the reported |
|
Correction to my earlier comparison: I attributed the committed wire-body tests to the wrong PR. The regression tests are in #2540; #2541's diff changes only the bundled pi-ai patch and lockfile, with the smoke verification described but not committed as tests. Given the reusable, host-level request tests and focused compatibility detection in #2540, I recommend consolidating on #2540 instead. The same current-main base-refresh blocker applies to both; neither should merge until one candidate is refreshed and all required gates pass. |
Mistral's Chat Completions endpoint (`https://api.mistral.ai/v1/chat/completions`) strictly rejects the OpenAI-only `store` field with HTTP 422 (`extra_forbidden`). Because pi-ai's `openai-completions` auto-detection does not classify Mistral as a non-standard endpoint, `supportsStore` defaulted to `true` and emitted `store: false`. Add `isMistralEndpoint` and `mistralRequestCompat` in `@pi-desktop/shared` and wire `supportsStore: false` in `buildProviderModel` for `openai-completions` bindings so Mistral requests omit `store` while preserving DeepSeek replay compatibility and OpenAI defaults. fixes vastsa#2539
|
Thanks for the follow-up review and re-checking the committed regression tests, @Tioit-Wang! I've rebased this branch cleanly onto current
Ready for CI and another look whenever you have a moment. |
deef429 to
66158df
Compare
|
This issue is fixed by merged PR #2562, which continues #2540 from the current main base and preserves your implementation commit. Its serialized request-body tests and refreshed CI pass. I am closing this superseded PR to avoid a duplicate merge. The broader |
Summary / 概要
Mistral's OpenAI-compatible Chat Completions endpoint (
https://api.mistral.ai/v1/chat/completions) strictly rejects the OpenAI-onlystorerequest body field with HTTP 422 (extra_forbidden). Because@earendil-works/pi-ai'sopenai-completionsdetectCompat()does not classify Mistral as a non-standard endpoint,supportsStoredefaulted totrueand emitted"store": falseon every request.This PR adds Mistral endpoint compatibility detection following the existing
zhipuRequestCompat/deepseekRequestCompatpattern:packages/shared/src/provider-presets.ts: AddedisMistralEndpoint()(matchingmistral.ai/*.mistral.aihostnames and themistralpreset while rejecting spoofed hostnames and rows repointed to another published vendor) andmistralRequestCompat()returning{ supportsStore: false }.packages/agent-runtime/src/provider-binding.ts: WiredmistralRequestCompat({ vendorKey: provider.vendorKey, baseUrl })intobuildProviderModel()foropenai-completionsbindings, omittingstorewithout disturbing DeepSeek reasoning replay compatibility or OpenAI defaults.packages/shared/src/provider-presets.test.tsand end-to-end wire-bodystreamSimpletests inpackages/agent-runtime/src/provider-binding.test.tscovering Mistral +deepseek-v4-1-flash-1017, Mistral native models, custom rows pointing atapi.mistral.ai, and unchanged OpenAI behavior.Requirement link / 需求关联
Verification
buildProviderModel+createProviderModels(...).streamSimple(..., { fetch }): bothdeepseek-v4-1-flash-1017andmistral-large-latestonhttps://api.mistral.ai/v1emitted"store": falsein the request JSON body."store"is omitted from the serialized JSON body for Mistral requests while DeepSeek reasoning replay flags (requiresReasoningContentOnAssistantMessages,supportsReasoningEffort: false,requiresNonEmptyReasoningReplay) and OpenAI"store": falseremain intact.pnpm --filter @pi-desktop/shared build && pnpm --filter @pi-desktop/shared typecheck— PASSpnpm --filter @pi-desktop/agent-runtime build && pnpm --filter @pi-desktop/agent-runtime typecheck— PASSpnpm --filter @pi-desktop/shared test— all test files PASS (provider-presets.test.ts: 31/31)pnpm --filter @pi-desktop/agent-runtime exec vitest run src/provider-binding.test.ts— 61/61 PASSpnpm lint:biome— 151 files checked, 0 errorspnpm check:pr-base— PASS (origin/mainis ancestor of HEAD)