fix(mistral): lower default maxTokens to prevent 422 rejection (#52599)#53006
fix(mistral): lower default maxTokens to prevent 422 rejection (#52599)#53006MoerAI wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…law#52599) Several Mistral model definitions had maxTokens set equal to contextWindow (up to 262144), which is sent as max_tokens in API requests. The Mistral API rejects oversized output budgets with 422. Lowered to realistic output limits consistent with the already-correct mistral-small-latest (16384) and codestral-latest (4096) values.
Greptile SummaryThis PR fixes HTTP 422 rejections from the Mistral API by correcting
Confidence Score: 2/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d11d6007ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export const MISTRAL_DEFAULT_MODEL_REF = `mistral/${MISTRAL_DEFAULT_MODEL_ID}`; | ||
| export const MISTRAL_DEFAULT_CONTEXT_WINDOW = 262144; | ||
| export const MISTRAL_DEFAULT_MAX_TOKENS = 262144; | ||
| export const MISTRAL_DEFAULT_MAX_TOKENS = 16384; |
There was a problem hiding this comment.
Rewrite saved Mistral configs to the new token limits
Lowering the catalog defaults here only fixes brand-new configs. Any user who already onboarded mistral-large-latest keeps the old maxTokens value, because applyProviderConfigWithDefaultModels reuses existingModels unchanged when the default model ID is already present (src/plugins/provider-onboarding-config.ts:111-119), and the runtime merge path prefers an explicit maxTokens over the implicit plugin catalog (src/agents/models-config.merge.ts:83-92). In that upgrade scenario, requests still go out with 262144 and continue to hit the same 422 this commit is trying to resolve.
Useful? React with 👍 / 👎.
| cost: { input: 0.5, output: 1.5, cacheRead: 0, cacheWrite: 0 }, | ||
| contextWindow: 128000, | ||
| maxTokens: 128000, | ||
| maxTokens: 40960, |
There was a problem hiding this comment.
Update the Mistral catalog test to these new limits
The extension test still asserts the old catalog values for magistral-small and pixtral-large-latest in extensions/mistral/model-definitions.test.ts:37-48, so this change leaves the Mistral plugin test red. Without updating that assertion alongside the catalog change, CI will fail even though the production behavior was intentionally modified.
Useful? React with 👍 / 👎.
|
closed in favour of #53006 |
Summary
Mistral AI returns HTTP 422 for all chat requests because several model definitions set
maxTokensequal tocontextWindow(up to 262144). This value is forwarded asmax_tokensin API requests, exceeding Mistral's actual output token limit.Root Cause
In
extensions/mistral/model-definitions.ts, five models hadmaxTokensset to their full context window size. Themax_tokensparameter controls output generation length, not input capacity — setting it to the context window size causes the API to reject the request.Two models already had correct values (
codestral-latest: 4096,mistral-small-latest: 16384), confirming this was an oversight.Changes
extensions/mistral/model-definitions.ts: LowerMISTRAL_DEFAULT_MAX_TOKENSand per-model output limits:src/commands/onboard-auth.test.ts: Update expected maxTokens assertionCloses #52599