fix: use max_completion_tokens for gpt-4.1+, gpt-5.x, and o-series models#38
Open
YuHuang0525 wants to merge 1 commit intoPickle-Pixel:mainfrom
Open
fix: use max_completion_tokens for gpt-4.1+, gpt-5.x, and o-series models#38YuHuang0525 wants to merge 1 commit intoPickle-Pixel:mainfrom
YuHuang0525 wants to merge 1 commit intoPickle-Pixel:mainfrom
Conversation
…dels Newer OpenAI models (gpt-4.1+, gpt-5.x, o1, o3, o4) reject the legacy max_tokens parameter with HTTP 400 and require max_completion_tokens instead. _chat_compat() now detects the model prefix at call time and sends the correct parameter, while all other providers (Gemini, local) continue using max_tokens unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Newer OpenAI models —
gpt-4.1,gpt-5.x,o1,o3,o4— reject the legacymax_tokensparameter with HTTP 400 and requiremax_completion_tokensinstead. This means any user who setsLLM_MODEL=gpt-5.2(or any other newer model) gets an immediate 400 error on every LLM call, breaking scoring, tailoring, and cover letter generation entirely.Relevant code before this fix (
llm.py_chat_compat()):Fix
Detect the model prefix at call time and send the correct parameter:
max_tokensas before.maxOutputTokensand is untouched.gpt-4o,gpt-4o-mini, or local model users.Testing
Verified manually with
gpt-5.2— the 400 error is resolved and completions return successfully after this change. No existing automated tests cover_chat_compat()directly.