Skip to content

fix(openai-shim): strip store when baseUrl points at Mistral#1047

Open
0xfandom wants to merge 1 commit into
Gitlawb:mainfrom
0xfandom:fix/739-strip-store-mistral-host
Open

fix(openai-shim): strip store when baseUrl points at Mistral#1047
0xfandom wants to merge 1 commit into
Gitlawb:mainfrom
0xfandom:fix/739-strip-store-mistral-host

Conversation

@0xfandom
Copy link
Copy Markdown
Contributor

@0xfandom 0xfandom commented May 7, 2026

Summary

Mistral's chat-completions endpoint rejects requests with a store field — 422 body.store: Extra inputs are not permitted (see #739). The shim already strips store for Gemini and Cerebras hosts via hasGeminiApiHost / hasCerebrasApiHost (PRs #959, #1040). Add the symmetric host check for Mistral so users hitting api.mistral.ai directly — without CLAUDE_CODE_USE_MISTRAL=1 to engage the gateway profile — don't hit the same wall.

Impact

Testing

  • Unit test: Mistral: strips unsupported store on chat_completions (#739) mirrors the Cerebras/Gemini cases, verifies request body has no store key.
  • bun test src/services/api/openaiShim.test.ts — 92 pass / 0 fail.
  • bun run build — bundle clean.
  • bun run smoke — 0.9.2 OK.

Notes

  • Scope: store-only, mirroring the merged Cerebras fix. Mistral also rejects max_completion_tokens for some models; users wanting full Mistral profile (including max_tokens mapping, devstral defaults) should set CLAUDE_CODE_USE_MISTRAL=1 to engage the gateway descriptor at src/integrations/gateways/mistral.ts.
  • Closes Mistral model issue #739.

kevincodex1
kevincodex1 previously approved these changes May 7, 2026
Copy link
Copy Markdown
Collaborator

@techbrewboss techbrewboss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Mistral host compatibility change and targeted regression test. The new predicate is narrowly used to strip only store, matching the existing Gemini/Cerebras handling for strict OpenAI-compatible hosts.

Verification: bun test src/services/api/openaiShim.test.ts passes, 92 tests / 0 failures.

@kevincodex1
Copy link
Copy Markdown
Contributor

hello @0xfandom this is good to merge, kindly rebase to main and fix conflicts

Copy link
Copy Markdown
Collaborator

@Vasanthdev2004 Vasanthdev2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Targeted review of current head 23d5a7e.

Verdict: Needs changes

The actual Mistral store stripping change is small and looks reasonable from the diff: it mirrors the existing Gemini/Cerebras host checks and adds a focused regression test for api.mistral.ai.

Current blocker:

  1. GitHub reports this branch as DIRTY / conflicting with main, so it cannot be merged or reliably final-approved as-is. Please rebase/merge latest main and resolve the conflicts, then the focused test should be rerun against the rebased branch.

No additional code-level blocker from me beyond the merge conflict state.

Copy link
Copy Markdown
Collaborator

@gnanam1990 gnanam1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Mistral store strip mirrors the existing Gemini/Cerebras pattern cleanly and is already approved by kevincodex1 and techbrewboss. Vasanthdev2004's CONFLICTING flag is still accurate — confirming a rebase is needed before merge.

Findings:

  1. git merge origin/main from PR head produces real conflicts in src/services/api/openaiShim.ts and src/services/api/openaiShim.test.ts. PR #1048 (strip store for vLLM/custom local providers) landed on main and edits the same shouldStripResponsesStore helper and adjacent test cases. Please rebase, resolve so hasMistralApiHost participates in the same OR chain as the new local-provider checks, and rerun the focused test.

Non-blocking:

  • Implementation itself is unchanged in value — only conflict resolution should be needed.
  • After rebase, bun test src/services/api/openaiShim.test.ts should still report all cases passing.

Verified locally: gh pr checkout 1047, git fetch origin main, git merge --no-commit --no-ff origin/main → CONFLICT in both files; git merge --abort clean.

@kevincodex1
Copy link
Copy Markdown
Contributor

hi bro @0xfandom this is good to merge kindly please rebase and fix conflicts

@0xfandom 0xfandom force-pushed the fix/739-strip-store-mistral-host branch from 23d5a7e to 4255ad1 Compare May 11, 2026 10:30
@0xfandom
Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (now at 7166400). Conflicts in src/services/api/openaiShim.ts and openaiShim.test.ts resolved against PR #1048hasMistralApiHost(...) joins the same OR chain as the local-provider check; Mistral test sits alongside the new local-provider test.

bun test src/services/api/openaiShim.test.ts → 93 pass / 0 fail.

Copy link
Copy Markdown
Collaborator

@Vasanthdev2004 Vasanthdev2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Targeted re-review of current head 4255ad1b, focused on the post-rebase Mistral store stripping fix.

Verdict: Approve-ready

What I checked:

  • The Mistral detection uses parsed URL host matching (api.mistral.ai / *.mistral.ai), so it avoids substring-based URL mistakes.
  • The change only joins the existing OpenAI-compatible provider compatibility gate that already strips unsupported store for Gemini/Cerebras/local providers.
  • The regression test verifies store is omitted for https://api.mistral.ai/v1.
  • CI is green on the current head.

Local validation:

  • bun test src/services/api/openaiShim.test.ts -> 93/93 passing
  • git diff --check main..HEAD -> clean

I do not see a remaining blocker on the current head.

Mistral's chat-completions endpoint rejects requests with a `store`
field — `422 body.store: Extra inputs are not permitted`. The shim
already strips `store` for Gemini and Cerebras hosts via
`hasGeminiApiHost` / `hasCerebrasApiHost`; add the symmetric host check
for Mistral so users hitting `api.mistral.ai` directly (without
`CLAUDE_CODE_USE_MISTRAL=1` to engage the gateway profile) don't hit
the same wall.

Closes Gitlawb#739.
@0xfandom 0xfandom force-pushed the fix/739-strip-store-mistral-host branch from 4255ad1 to 9591318 Compare May 11, 2026 14:16
@0xfandom
Copy link
Copy Markdown
Contributor Author

0xfandom commented May 11, 2026

Rebased onto latest main (now at f9621ab). No conflicts this round — upstream PR #1109 (Venice provider) touched src/services/api/openaiShim.{ts,test.ts} but in disjoint regions from the Mistral host detection.

bun test src/services/api/openaiShim.test.ts → 93 pass / 0 fail.

Ready for merge. @kevincodex1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mistral model issue

5 participants