Skip to content

fix(chat): send max_completion_tokens to GPT-5 models in OpenAIChat - #498

Open
pcbeingused33 wants to merge 4 commits into
StarTrail-org:mainfrom
pcbeingused33:fix/openai-gpt5-params
Open

pcbeingused33 wants to merge 4 commits into
StarTrail-org:mainfrom
pcbeingused33:fix/openai-gpt5-params

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

What does this PR do?

OpenAIChat.ask only treats o1, o3 and o4 as reasoning models. A GPT-5 model, for example leann ask <index> --llm openai --llm-model gpt-5, gets max_tokens and temperature=0.7. The Chat Completions API rejects max_tokens and a non-default temperature for GPT-5 reasoning models, so the user gets Error: Could not get a response from OpenAI instead of an answer.

gpt-5* model names now take the same branch as the o-series: max_completion_tokens and temperature=1.0. This also applies to prefixed names such as openai/gpt-5.5. Other models are sent the same parameters as before.

--thinking-budget handling is unchanged by this PR, so it is still not forwarded as reasoning_effort for GPT-5 models.

The new tests mock the OpenAI client and check the request parameters. The four GPT-5 cases fail on main and pass with this change; the gpt-4o case passes on both. No live API call was made.

Related Issues

None filed. Found by reading the other providers in chat.py after #477.

Checklist

  • New tests pass (pytest tests/test_openai_chat_gpt5_params.py); the full suite was not run
  • Code formatted (ruff format and ruff check on the changed Python files)
  • Pre-commit hooks pass (pre-commit run --all-files)

This change was prepared with the help of an AI coding assistant.

@ASuresh0524

Copy link
Copy Markdown
Collaborator

Heads up — this now conflicts with main, and it's my fault rather than anything you did.

I merged eight other pull requests just now (#473, #485, #486, #489, #492, #493, #494, #499). Each appended its own entry to docs/CHANGELOG.md, which is an append-only file, so every one of them collides with yours at the bottom. docs/CHANGELOG.md is the only conflicting file — your actual change is untouched and your CI was green at 31/31 before this.

Resolving it is just keeping both entries: main's new entries above yours, since the file runs oldest-first with the newest at the bottom.

git fetch origin main
git merge origin/main
# keep both sides in docs/CHANGELOG.md, main's entries first
git add docs/CHANGELOG.md && git commit --no-edit && git push

I tried to do this for you directly and my environment blocks pushing to contributor forks, so it needs your hands. Once it's pushed I'll merge it — no re-review needed, the change itself hasn't moved.

Sorry for the churn. Merging a batch into an append-only changelog guarantees this, and the four of you drew the short straw on ordering.

🤖 Generated with Claude Code

ASuresh0524 added a commit that referenced this pull request Dec 3, 2026
CLAUDE.md asks every contributor to append an entry to
docs/CHANGELOG.md, and the file is append-only, so any two concurrent
pull requests collide at the bottom of it even when their code does not
overlap. Merging a batch makes that quadratic: each merge re-conflicts
every pull request still open.

That is not hypothetical. Merging eight pull requests broke the four
still in the queue (#487, #491, #495, #498) with docs/CHANGELOG.md as
the only conflicting file in all four; their authors each resolved it,
and merging #487 immediately re-broke the remaining three the same way.

`union` is a built-in git merge driver that keeps the lines from both
sides rather than writing conflict markers, which is the right
resolution for an append-only log. Verified against the three pull
requests this had just blocked, with the file as the only variable:

  without .gitattributes:  #498 CONFLICT  #491 CONFLICT  #495 CONFLICT
  with .gitattributes:     #498 clean     #491 clean     #495 clean

Scope: this is verified for git merges, which is where contributors
resolve. Whether GitHub's own merge-button machinery honours the
attribute server-side is untested. Ordering inside a merged region
follows the two sides, so the result still wants a glance when entry
order carries meaning.

No changelog entry for this one, deliberately: it is a repository
tooling change rather than a user-visible feature or fix, and adding an
entry would contribute to the problem it removes.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@ASuresh0524

Copy link
Copy Markdown
Collaborator

This is green on its own merits and just needs main merged in. One command, and it will not ask you to resolve anything:

git fetch origin main && git merge origin/main && git push

Two things changed on main that make this painless now:

Once it is pushed I will merge — no re-review needed, your change itself has not moved.

🤖 Generated with Claude Code

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.

2 participants